NextRush

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

Loading diagram...

Overview

PackagePurposeSize
nextrushMeta package with all essentialsRe-exports
@nextrush/coreApplication, middleware composition~500 LOC
@nextrush/routerRadix tree routing~600 LOC
@nextrush/typesTypeScript type definitions~400 LOC
@nextrush/errorsHTTP error classes~300 LOC
@nextrush/runtimeRuntime detection~400 LOC
@nextrush/devDevelopment 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 reload
  • nextrush 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 wrapper
  • Middleware — Middleware function signature
  • Plugin — Plugin interface
  • HttpMethod — HTTP method types
  • Runtime — 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:

  • Application class — The container for middleware and plugins
  • createApp() — Factory function
  • compose() — 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:

  • Router class — Radix tree router
  • createRouter() — 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

On this page