CLI

next typegen

Run the installed Next.js typegen command before TypeScript checking. This creates generated route types and next-env.d.ts without a full production build. Config loads in the production phase, so reviewed dependencies and required environment inputs must be available. The command does not run route logic or validate untrusted parameters. Source: https://nextjs.org/docs/app/api-reference/cli/next. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
next typegen [directory]

Working Example

Example Snippetnextjs
./node_modules/.bin/next typegen./node_modules/.bin/tsc --noEmit
Next.js Reference