-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Tanzim Hossain edited this page Apr 28, 2026
·
4 revisions
Path from empty directory to a responding server. For copy-paste examples with more commentary, use the docs site: Installation, Quick start.
| Tool | Version |
|---|---|
| Node.js | >= 22 |
| pnpm | current |
| TypeScript | 5.x |
pnpm create nextrush my-api
cd my-api
pnpm devThe CLI asks for style (functional / class-based / full), middleware preset, and runtime target.
pnpm add nextrushnextrush pulls in core, router, Node adapter, errors, and types.
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"outDir": "./dist"
}
}For @Controller and DI:
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}import { createApp, createRouter, listen } from 'nextrush';
const app = createApp();
const router = createRouter();
router.get('/', (ctx) => {
ctx.json({ message: 'Hello NextRush!' });
});
app.route('/', router);
listen(app, 3000);npx tsx src/index.tspnpm add @nextrush/di @nextrush/decorators @nextrush/controllersimport 'reflect-metadata';
import { createApp, listen } from 'nextrush';
import { Controller, Get, Service, controllersPlugin } from '@nextrush/controllers';
@Service()
class GreetingService {
greet() {
return { message: 'Hello NextRush!' };
}
}
@Controller('/')
class GreetingController {
constructor(private greetingService: GreetingService) {}
@Get()
greet() {
return this.greetingService.greet();
}
}
const app = createApp();
app.plugin(controllersPlugin({ root: './src' }));
listen(app, 3000);pnpm add @nextrush/cors @nextrush/body-parser @nextrush/helmetimport { createApp, createRouter, listen } from 'nextrush';
import { cors } from '@nextrush/cors';
import { json } from '@nextrush/body-parser';
import { helmet } from '@nextrush/helmet';
const app = createApp();
app.use(helmet());
app.use(cors());
app.use(json());
const router = createRouter();
router.post('/users', (ctx) => {
const { name } = ctx.body as { name: string };
ctx.status = 201;
ctx.json({ id: Date.now(), name });
});
app.route('/', router);
listen(app, 3000);Order matters: security and CORS before body parsing before routes. See Middleware.
const app = createApp({
env: 'production',
proxy: true,
logger: console,
});proxy: true trusts X-Forwarded-* when behind a reverse proxy.
NextRush · MIT License · Docs · Issues