Skip to main content

Installation

npm install nextjs-nestapi class-validator class-transformer

class-validator and class-transformer are peer dependencies — @Body() uses them for DTO validation, so they must be installed in your project alongside this package.

Enable decorators

tsconfig.json needs decorator support enabled:

tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}

Starting fresh?

If you don't have a Next.js project yet, use the CLI to create one already wired with nextjs-nestapi:

npx nextjs-nestapi new my-app

This runs create-next-app, wires app.ts + the catch-all API route, patches tsconfig.json, and installs everything above for you.