Overview
Complete reference for all NextRush packages — types, methods, and configuration options.
Every NextRush package is documented with full type signatures, method descriptions, and usage examples. Install only what you need. See the Packages A-Z index for a flat alphabetical lookup by npm name.
Which package do I need?
Start with nextrush — it includes routing, middleware, and the Node.js server. Add a package only when a specific need comes up:
| I want to… | Install | Reference |
|---|---|---|
| Parse JSON / form request bodies | @nextrush/body-parser | body-parser |
| Handle file uploads (multipart) | @nextrush/form-data | form-data |
| Validate requests (Zod/Valibot/ArkType) | @nextrush/validation | validation |
| Generate OpenAPI docs from routes | @nextrush/openapi | openapi |
| Stream AI/LLM responses (SSE, NDJSON) | @nextrush/stream | stream |
| Allow cross-origin requests (CORS) | @nextrush/cors | cors |
| Set security headers | @nextrush/helmet | helmet |
| Rate-limit endpoints | @nextrush/rate-limit | rate-limit |
| Compress responses (gzip/brotli) | @nextrush/compression | compression |
| Read / write cookies | @nextrush/cookies | cookies |
| Protect against CSRF | @nextrush/csrf | csrf |
| Add request IDs for tracing | @nextrush/request-id | request-id |
| Measure response time | @nextrush/timer | timer |
| Liveness/readiness probes | @nextrush/health | health |
| Serve static files | @nextrush/static | static |
| Add WebSocket support | @nextrush/websocket | websocket |
| Render HTML templates | @nextrush/template | template |
| Emit structured logs | @nextrush/logger | logger |
| Use a type-safe event emitter | @nextrush/events | events |
| Build class-based controllers | @nextrush/class | class |
| Inject dependencies (DI) | @nextrush/class (re-exports @nextrush/di) | class → di |
| Run on Bun, Deno, Edge, or serverless | @nextrush/adapter-bun · -deno · -edge · -serverless | platforms |
| Hot-reload dev server & build | @nextrush/dev | dev |
The full catalog with size budgets is in Packages A-Z.
Package Architecture
Quick Start
For most projects, install the meta package:
$ pnpm add nextrush
This gives you:
createApp()— Application factorycreateRouter()— Router factorylisten()— Start Node.js server- HTTP error classes
- Essential types
import { createApp, createRouter, listen } from 'nextrush';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => ctx.json({ hello: 'world' }));
app.route('/', router);
await listen(app, 8080);Package Categories
Core Foundation
The foundational packages that everything else builds on.
| Package | Purpose | Install Separately? |
|---|---|---|
nextrush | Meta package with all essentials | Start here |
@nextrush/core | Application, middleware composition | Usually via nextrush |
@nextrush/router | Segment trie routing | Usually via nextrush |
@nextrush/types | TypeScript type definitions | Re-exported by nextrush; install directly for advanced package work |
@nextrush/errors | HTTP error classes | Usually via nextrush |
@nextrush/runtime | Runtime detection | Usually via adapter |
@nextrush/dev | Development server & build tools | Dev dependency |
Platforms
Connect NextRush to your runtime environment.
| Package | Runtime | Notes |
|---|---|---|
@nextrush/adapter-node | Node.js | Included in nextrush |
@nextrush/adapter-bun | Bun | Install separately |
@nextrush/adapter-deno | Deno | Install separately |
@nextrush/adapter-edge | Edge (Cloudflare, Vercel) | Install separately |
@nextrush/adapter-serverless | AWS Lambda and other event-driven platforms | Install separately |
Middleware
Middleware packages for common HTTP concerns.
| Package | Purpose |
|---|---|
@nextrush/cors | Cross-Origin Resource Sharing |
@nextrush/helmet | Security headers |
@nextrush/body-parser | Request body parsing |
@nextrush/rate-limit | Rate limiting |
@nextrush/compression | Response compression |
@nextrush/cookies | Cookie handling |
@nextrush/request-id | Request ID generation |
@nextrush/timer | Response timing |
@nextrush/form-data | Multipart form parsing |
@nextrush/csrf | CSRF protection |
@nextrush/health | Liveness/readiness endpoints |
Extensions & Plugins
Extend NextRush with additional capabilities.
| Package | Purpose |
|---|---|
@nextrush/logger | Structured logging |
@nextrush/static | Static file serving |
@nextrush/websocket | WebSocket support |
@nextrush/events | Event emitter integration |
@nextrush/template | Template engine integration |
Class Runtime
For class-based applications with decorators, dependency injection, and modules.
| Package | Purpose |
|---|---|
@nextrush/class | Decorators, controllers, modules, guards, interceptors, filters, and a re-export of @nextrush/di — the single import surface (nextrush/class) |
@nextrush/di | Dependency injection container (used directly by @nextrush/class) |
@nextrush/decorators and @nextrush/controllers were removed
Both were compatibility shims that re-exported from @nextrush/class — they no longer publish
new versions. Import from nextrush/class directly — see
@nextrush/class reference and
Deprecations for the migration map and codemod.
$ pnpm add @nextrush/class
Choosing Packages
Functional Style (Recommended for Most)
import { createApp, createRouter, listen } from 'nextrush';
import { cors } from '@nextrush/cors';
import { json } from '@nextrush/body-parser';
const app = createApp();
app.use(cors());
app.use(json());
const router = createRouter();
router.get('/users', (ctx) => ctx.json([]));
app.route('/', router);
await listen(app, 8080);Install:
$ pnpm add nextrush @nextrush/cors @nextrush/body-parser
Class-Based Style (For Larger Apps)
import { createApp, listen } from 'nextrush';
import { registerControllers, Controller, Get, Service } from 'nextrush/class';
@Service()
class UserService {
findAll() {
return [{ id: 1, name: 'Alice' }];
}
}
@Controller('/users')
class UserController {
constructor(private users: UserService) {}
@Get()
findAll() {
return this.users.findAll();
}
}
const app = createApp();
await registerControllers(app, { root: './src', prefix: '/api' });
await listen(app, 8080);Install:
$ pnpm add nextrush @nextrush/class
Non-Node.js Runtimes
For Bun, Deno, or Edge runtimes, install the specific adapter:
// Bun
import { createApp } from '@nextrush/core';
import { serve } from '@nextrush/adapter-bun';
const app = createApp();
serve(app, { port: 8080 });Install:
$ pnpm add @nextrush/core @nextrush/router @nextrush/adapter-bun
Package Size Philosophy
NextRush follows a strict size budget:
| Category | Max LOC | Rationale |
|---|---|---|
| Core packages | 500-1,500 | Foundation must be minimal |
| Platforms | ~500 | Thin adapters, no bloat |
| Middleware | ~300 | Single responsibility |
| Extensions & Plugins | ~600 | Focused features |
This ensures:
- Fast installation
- Quick cold starts
- Low memory footprint
- Transparent auditing
What's Next?
Release Handbook
How NextRush versions and ships ~35 packages — the full lifecycle, CLI vs CI, and every real mistake we've already made so you don't repeat them.
All Packages (A-Z)
Every publishable NextRush package in one alphabetical index, tagged by capability category and linked to its API reference.