-
Notifications
You must be signed in to change notification settings - Fork 0
Adapters
The adapter is the platform entry point. It translates HTTP (Node.js, Bun, Deno, or Worker-style fetch) into NextRush's Context, runs the application, and sends the response back.
Same code runs on any adapter; you choose at startup.
| Adapter | Platform | Entry | Install |
|---|---|---|---|
@nextrush/adapter-node |
Node.js ≥22 | listen(app, port) |
nextrush (included) |
@nextrush/adapter-bun |
Bun |
listen(app, port) or serve(app, {…})
|
pnpm add @nextrush/adapter-bun |
@nextrush/adapter-deno |
Deno | listen(app, port) |
pnpm add @nextrush/adapter-deno |
@nextrush/adapter-edge |
Cloudflare Workers, Vercel Edge | toFetchHandler(app) |
pnpm add @nextrush/adapter-edge |
import { createApp, createRouter, listen } from 'nextrush';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => {
ctx.json({ message: 'Hello' });
});
app.route('/', router);
listen(app, 3000);listen starts an HTTP server on port 3000. Graceful shutdown: await app.close().
import { createApp, listen } from '@nextrush/adapter-bun';
const app = createApp();
// …routes…
listen(app, 3000);Or use serve() for more control:
import { serve } from '@nextrush/adapter-bun';
const handler = serve(app, {
port: 3000,
hostname: '0.0.0.0',
trustProxy: true,
});import { createApp, listen } from '@nextrush/adapter-deno';
const app = createApp();
// …routes…
listen(app, 3000);Runs under Deno's HTTP server (requires --allow-net permission).
Returns a fetch handler for serverless deployment:
import { createApp } from 'nextrush';
import { toFetchHandler } from '@nextrush/adapter-edge';
const app = createApp();
// …routes…
const handler = toFetchHandler(app);
export default {
fetch: handler,
};All adapters produce the same Context object:
flowchart LR
Node["Node.js<br/>IncomingMessage"]
Bun["Bun<br/>Request"]
Deno["Deno<br/>Request"]
Edge["Edge<br/>Request"]
Node -->|→ ctx| C["Context<br/>method, path<br/>params, query<br/>body, headers<br/>status, json()"]
Bun -->|→ ctx| C
Deno -->|→ ctx| C
Edge -->|→ ctx| C
C --> App["Application<br/>middleware<br/>routing<br/>handlers"]
Code in middleware and handlers never checks what platform it's on; it just uses ctx.
Behind a reverse proxy (load balancer, nginx), set proxy: true on the app:
const app = createApp({ proxy: true });Then adapters trust X-Forwarded-* headers for client IP and protocol. Without proxy: true, those headers are ignored (safe default).
Choose the adapter that matches your deployment target:
- Local dev: Node, Bun, Deno (all start fast)
- Production on servers: Bun or Node
- Serverless: Edge adapter
Code is identical across all targets; only the entry file changes.
NextRush · MIT License · Docs · Issues