NextRush

API Reference

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.

Package Architecture

Loading diagram...

Quick Start

For most projects, install the meta package:

$ pnpm add nextrush

This gives you:

  • createApp() — Application factory
  • createRouter() — Router factory
  • listen() — 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, 3000);

Package Categories

Core Foundation

The foundational packages that everything else builds on.

PackagePurposeInstall Separately?
nextrushMeta package with all essentialsStart here
@nextrush/coreApplication, middleware compositionUsually via nextrush
@nextrush/routerRadix tree routingUsually via nextrush
@nextrush/typesTypeScript type definitionsRe-exported by nextrush; install directly for advanced package work
@nextrush/errorsHTTP error classesUsually via nextrush
@nextrush/runtimeRuntime detectionUsually via adapter
@nextrush/devDevelopment server & build toolsDev dependency

Runtime Adapters

Connect NextRush to your runtime environment.

PackageRuntimeNotes
@nextrush/adapter-nodeNode.jsIncluded in nextrush
@nextrush/adapter-bunBunInstall separately
@nextrush/adapter-denoDenoInstall separately
@nextrush/adapter-edgeEdge (Cloudflare, Vercel)Install separately

Middleware

Middleware packages for common HTTP concerns.

PackagePurpose
@nextrush/corsCross-Origin Resource Sharing
@nextrush/helmetSecurity headers
@nextrush/body-parserRequest body parsing
@nextrush/rate-limitRate limiting
@nextrush/compressionResponse compression
@nextrush/cookiesCookie handling
@nextrush/request-idRequest ID generation
@nextrush/timerResponse timing
@nextrush/multipartMultipart form parsing
@nextrush/csrfCSRF protection

Plugins

Extend NextRush with additional capabilities.

PackagePurpose
@nextrush/controllersClass-based controllers with DI
@nextrush/loggerStructured logging
@nextrush/staticStatic file serving
@nextrush/websocketWebSocket support
@nextrush/eventsEvent emitter integration
@nextrush/templateTemplate engine integration

Dependency Injection

For class-based applications with decorators.

PackagePurpose
@nextrush/diDependency injection container
@nextrush/decoratorsController, route, and guard decorators
$ pnpm add @nextrush/di @nextrush/decorators @nextrush/controllers

Choosing Packages

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, 3000);

Install:

$ pnpm add nextrush @nextrush/cors @nextrush/body-parser

Class-Based Style (For Larger Apps)

import { createApp, createRouter, listen } from 'nextrush';
import { controllersPlugin, 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();
const router = createRouter();
await app.plugin(controllersPlugin({ router, root: './src', prefix: '/api' }));
app.route('/', router);
await listen(app, 3000);

Install:

$ pnpm add nextrush @nextrush/di @nextrush/decorators @nextrush/controllers

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: 3000 });

Install:

$ pnpm add @nextrush/core @nextrush/router @nextrush/adapter-bun

Package Size Philosophy

NextRush follows a strict size budget:

CategoryMax LOCRationale
Core packages500-1,500Foundation must be minimal
Adapters~500Thin adapters, no bloat
Middleware~300Single responsibility
Plugins~600Focused features

This ensures:

  • Fast installation
  • Quick cold starts
  • Low memory footprint
  • Transparent auditing

What's Next?

On this page