Skip to content

nextjs

npm version License: MIT Node.js TypeScript Next.js

> TypeScript configuration for Next.js apps (App Router and Pages Router). Extends @jmlweb/tsconfig-react with incremental builds, the Next.js plugin and an @/* alias.

  • ๐Ÿš€ Next.js Plugin: enhanced type checking for Next.js APIs
  • โšก Incremental Builds: incremental: true for faster rebuilds
  • ๐Ÿ“ Path Alias: @/* maps to the project root
  • โš›๏ธ React Ready: inherits JSX, DOM types and bundler resolution
  • ๐Ÿ”’ Strict Mode: inherits every strict flag from the base config
Terminal window
npm install --save-dev @jmlweb/tsconfig-nextjs @jmlweb/tsconfig-react @jmlweb/tsconfig-base next typescript
{
"extends": "@jmlweb/tsconfig-nextjs",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
{
"extends": "@jmlweb/tsconfig-nextjs",
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

Overriding paths replaces the default @/* entry.

{
"extends": "@jmlweb/tsconfig-nextjs",
"compilerOptions": {
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}

Extends @jmlweb/tsconfig-react (which extends @jmlweb/tsconfig-base) and adds:

Option Value Description
incremental true Reuse previous compilation info
plugins [{ "name": "next" }] Next.js TypeScript plugin
paths { "@/*": ["./*"] } @/* alias pointing to project root

Inherited from the React config: jsx: "react-jsx", module: "ESNext", moduleResolution: "bundler", lib: ["ES2022", "DOM", "DOM.Iterable"].

incremental writes a .tsbuildinfo file; add it to .gitignore.

  • โœ… Next.js apps with the App Router or Pages Router
  • โœ… Projects that want the @/* import convention

Plain React: use @jmlweb/tsconfig-react.

{
"extends": "@jmlweb/tsconfig-nextjs",
"compilerOptions": {
"noEmit": true,
"paths": {
"~/*": ["./src/*"]
}
}
}
{
"scripts": {
"dev": "next dev",
"build": "next build",
"typecheck": "tsc --noEmit"
}
}
Terminal window
npm run typecheck
  • Node.js >= 22.12.0
  • TypeScript >= 5.0.0
  • Next.js >= 13.0.0
  • @jmlweb/tsconfig-react (^2.0.0), which itself requires @jmlweb/tsconfig-base (^2.0.0)
  • next (>=13.0.0)
  • typescript (>=5.0.0)

Breaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).

  1. Upgrade Node.js to 22.12.0 or later.
  2. Update the package: npm install --save-dev @jmlweb/tsconfig-nextjs@^2.0.0.

The compilerOptions are unchanged. See the Changelog.

MIT