Core Packages
The foundational packages that power NextRush
These packages form the foundation of NextRush. Everything else builds on top of them.
Package Dependency Flow
Overview
| Package | Purpose | Size |
|---|---|---|
nextrush | Meta package with all essentials | Re-exports |
@nextrush/core | Application, middleware composition | ~500 LOC |
@nextrush/router | Radix tree routing | ~600 LOC |
@nextrush/types | TypeScript type definitions | ~400 LOC |
@nextrush/errors | HTTP error classes | ~300 LOC |
@nextrush/runtime | Runtime detection | ~400 LOC |
@nextrush/dev | Development server & build tools | ~800 LOC |
Quick Start
For most Node.js projects, install the meta package:
$ pnpm add nextrush
This gives you everything you need to build APIs:
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);When to Install Directly
Direct installation needed when:
- Using Bun, Deno, or Edge runtimes (no Node adapter bundled)
- Building custom tooling on top of NextRush
- You want fine-grained control over dependencies
$ pnpm add @nextrush/core @nextrush/router
The Meta Package
nextrush bundles the essentials:
@nextrush/core— Application and middleware@nextrush/router— Routing@nextrush/adapter-node— Node.js HTTP handling@nextrush/errors— HTTP error classes@nextrush/types— TypeScript types
One install, one import path.
The Dev Package
@nextrush/dev provides development tooling:
nextrush dev— Development server with hot reloadnextrush build— Production build with decorator metadata- Multi-runtime support (Node.js, Bun, Deno)
npx nextrush dev
npx nextrush build$ pnpm add -D @nextrush/dev
The Types Package
@nextrush/types is the foundation. It defines:
Context— The request/response wrapperMiddleware— Middleware function signaturePlugin— Plugin interfaceHttpMethod— HTTP method typesRuntime— Runtime identifier
All other packages depend on types. It has zero runtime dependencies.
import type { Context, Middleware, Plugin } from '@nextrush/types';The Core Package
@nextrush/core provides:
Applicationclass — The container for middleware and pluginscreateApp()— Factory functioncompose()— Middleware composition
import { createApp, compose } from '@nextrush/core';
const app = createApp();
app.use(async (ctx) => {
console.log(`${ctx.method} ${ctx.path}`);
await ctx.next();
});The Router Package
@nextrush/router provides:
Routerclass — Radix tree routercreateRouter()— Factory function- Route parameters, wildcards, groups
import { createRouter } from '@nextrush/router';
const router = createRouter();
router.get('/users/:id', (ctx) => {
ctx.json({ id: ctx.params.id });
});
app.route('/', router);The Errors Package
@nextrush/errors provides:
HttpError— Base HTTP error class- Pre-built errors (NotFound, BadRequest, Unauthorized, etc.)
- Error handling middleware
import { NotFoundError, BadRequestError } from '@nextrush/errors';
if (!user) throw new NotFoundError('User not found');
if (!email) throw new BadRequestError('Email required');The Runtime Package
@nextrush/runtime provides:
- Runtime detection (Node.js, Bun, Deno, Edge)
- Cross-runtime body source abstraction
- Runtime capability checks
import { getRuntime, isNode, isBun } from '@nextrush/runtime';
const runtime = getRuntime(); // 'node' | 'bun' | 'deno' | 'edge'
if (isBun()) {
console.log('Running on Bun!');
}Detailed Documentation
nextrush
Meta package with all essentials for Node.js.
@nextrush/core
Application class, middleware composition, plugin system.
@nextrush/router
Radix tree routing with O(k) performance.
@nextrush/types
TypeScript type definitions.
@nextrush/errors
HTTP error classes and handling.
@nextrush/runtime
Runtime detection and abstractions.
@nextrush/dev
Development server and build tools.