API ReferenceAdapters
Runtime Adapters
Connect NextRush to Node.js, Bun, Deno, or Edge runtimes
Adapters connect your NextRush application to the underlying runtime's HTTP server.
Why Adapters?
NextRush's core is runtime-agnostic. The Application class doesn't know about HTTP servers—it only knows about middleware and context objects.
Adapters bridge this gap:
Loading diagram...
Each adapter:
- Creates a platform-specific request handler
- Converts native requests to
Contextobjects - Converts context responses back to native responses
- Manages server lifecycle (start, stop, graceful shutdown)
Node.js Included by Default
The Node.js adapter is bundled with the nextrush meta package. Install platform-specific
adapters separately only when targeting Bun, Deno, or Edge runtimes.
Available Adapters
| Package | Runtime | Install Separately? |
|---|---|---|
@nextrush/adapter-node | Node.js | Included in nextrush |
@nextrush/adapter-bun | Bun | Yes |
@nextrush/adapter-deno | Deno | Yes |
@nextrush/adapter-edge | Edge (Cloudflare, Vercel) | Yes |
Quick Comparison
Each runtime uses a different adapter import. The application logic stays the same.
import { createApp, createRouter, listen } from 'nextrush';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => ctx.json({ runtime: 'node' }));
app.route('/', router);
await listen(app, 3000);import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { serve } from '@nextrush/adapter-bun';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => ctx.json({ runtime: 'bun' }));
app.route('/', router);
serve(app, { port: 3000 });import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { serve } from '@nextrush/adapter-deno';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => ctx.json({ runtime: 'deno' }));
app.route('/', router);
await serve(app, { port: 3000 });import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { createHandler } from '@nextrush/adapter-edge';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => ctx.json({ runtime: 'edge' }));
app.route('/', router);
export default {
fetch: createHandler(app),
};Common API
All adapters export similar functions:
| Function | Description |
|---|---|
serve(app, options) | Start HTTP server |
listen(app, port) | Shorthand with default logging |
createHandler(app) | Create request handler function |
Choosing an Adapter
| Runtime | Often chosen when |
|---|---|
| Node.js | You need the broadest ecosystem and existing Node deployments |
| Bun | You want a fast JS runtime with strong Node compatibility where supported |
| Deno | You want permissions, TypeScript-first tooling, or Deno Deploy |
| Edge | You deploy to isolates or regional workers with fetch-only I/O |
Runtime Capabilities
Different runtimes have different capabilities:
| Capability | Node.js | Bun | Deno | Edge |
|---|---|---|---|---|
| File System | ✅ | ✅ | ✅ | ❌ |
| WebSocket | ✅ | ✅ | ✅ | ✅ |
| Native Fetch | ✅ | ✅ | ✅ | ✅ |
| Worker Threads | ✅ | ✅ | ✅ | ⚠️ |
| Node.js APIs | ✅ | ✅ | ⚠️ | ❌ |
| Cold start feel | Typical | Often low | Typical | Often lowest (host-dependent) |
Same Code, Any Runtime
Write your application logic once:
import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
export const app = createApp();
export const router = createRouter();
router.get('/health', (ctx) => {
ctx.json({ status: 'healthy' });
});
app.route('/', router);Then deploy anywhere:
import { app } from './app';
import { listen } from '@nextrush/adapter-node';
await listen(app, 3000);import { app } from './app';
import { serve } from '@nextrush/adapter-bun';
serve(app, { port: 3000 });import { app } from './app';
import { createHandler } from '@nextrush/adapter-edge';
export default { fetch: createHandler(app) };