Custom Routes
Nile's REST interface is a standard Hono app. After creating your server, you can add custom routes directly on the Hono instance for things Nile doesn't handle through the service/action model — webhooks, OAuth callbacks, health checks, or any traditional HTTP endpoint.
Accessing the Hono App
createNileServer returns a NileServer object with a rest.app property — a regular Hono instance:
Adding Routes
Use any Hono method (get, post, put, delete, all) to register custom routes:
Webhook Endpoint
OAuth Callback
Custom Health Check
Using Nile Context in Custom Routes
Access the shared NileContext from custom routes using getContext:
Adding Middleware
You can also add Hono middleware to the app for custom routes:
Route Order
Custom routes registered after createNileServer are added after Nile's built-in routes. The order is:
- CORS middleware
- Rate limiting middleware
- Static file serving (
/assets/*) POST {baseUrl}/services(Nile RPC)GET /status(if enabled)- Your custom routes
- 404 handler
Since Nile's 404 handler catches unmatched routes, register your custom routes before exporting the app for serving.