npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jmlweb/tsconfig-nextjs

v1.1.7

Published

TypeScript configuration for Next.js applications with App Router and Pages Router support

Readme

@jmlweb/tsconfig-nextjs

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

TypeScript configuration for Next.js applications. Extends @jmlweb/tsconfig-react with Next.js-specific optimizations, incremental builds, and path aliases.

✨ Features

  • 🔒 Strict Type Checking: Inherits all strict TypeScript rules from base configs
  • ⚛️ React Support: Full JSX support with modern React transform
  • 🚀 Next.js Optimized: Incremental builds and Next.js TypeScript plugin
  • 📁 Path Aliases: Pre-configured @/* path alias for clean imports
  • 🎯 App Router Ready: Optimized for Next.js App Router and Pages Router
  • 🌐 DOM Types: Includes DOM and DOM.Iterable libs for browser APIs
  • 📦 Bundler Resolution: Optimized moduleResolution: "bundler" for Next.js

📦 Installation

pnpm add -D @jmlweb/tsconfig-nextjs typescript next @jmlweb/tsconfig-react @jmlweb/tsconfig-base

💡 Upgrading from a previous version? See the Migration Guide for breaking changes and upgrade instructions.

🚀 Quick Start

Create a tsconfig.json file in your Next.js project root:

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

💡 Examples

Basic Next.js Setup (App Router)

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

Next.js with Custom Path Aliases

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

Next.js Pages Router

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

Next.js with Additional Compiler Options

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

🤔 Why Use This?

Philosophy: Next.js projects need TypeScript configured for both server and client code with incremental builds and framework-specific optimizations.

This package provides a TypeScript configuration specifically optimized for Next.js applications. It extends the React configuration while adding Next.js-specific settings like incremental compilation, the Next.js TypeScript plugin, and sensible path aliases that work with Next.js's file-based routing.

Design Decisions

Incremental Compilation (incremental: true): Faster rebuilds for development

  • Why: Next.js projects are often large with many files. Incremental compilation dramatically speeds up subsequent builds by only recompiling changed files and their dependents. This makes the development experience much faster
  • Trade-off: Creates a .tsbuildinfo file that needs to be gitignored. But the build speed improvement is worth it
  • When to override: Never - there's no downside to incremental compilation in Next.js projects

Next.js TypeScript Plugin: Framework-specific type checking

  • Why: Next.js has special conventions (Server Components, Route Handlers, Metadata API, etc.) that benefit from enhanced type checking. The plugin provides better autocomplete and catches Next.js-specific errors that generic TypeScript can't detect
  • Trade-off: Adds a dependency on Next.js being installed. But if you're using this config, you're already using Next.js
  • When to override: Only if the plugin causes issues (rare), but report bugs to Next.js if found

Path Aliases (@/* → project root): Clean imports for Next.js file structure

  • Why: Next.js projects have deep file structures (app/components/ui/button/index.tsx). Path aliases like @/components/ui/button are more readable and easier to refactor than ../../../components/ui/button. The @/* convention is standard in Next.js projects
  • Trade-off: Need to configure the same alias in next.config.js for runtime (though Next.js 13+ does this automatically from tsconfig.json)
  • When to override: If your team prefers a different alias convention (like ~/*), but @/* is the Next.js convention

📋 Configuration Details

What's Included

This configuration extends @jmlweb/tsconfig-react and adds:

  • Incremental Builds: incremental: true for faster compilation
  • Next.js Plugin: TypeScript plugin for Next.js-specific type checking
  • Path Aliases: Default @/* alias pointing to project root
  • All React Config: Inherits JSX support, DOM types, and bundler resolution
  • All Base Config: Inherits strict type checking and best practices

Next.js TypeScript Plugin

The Next.js TypeScript plugin provides:

  • ✅ Enhanced type checking for Next.js APIs
  • ✅ Better autocomplete for Next.js components
  • ✅ Type safety for App Router and Pages Router
  • ✅ Support for Next.js-specific features

Incremental Builds

Incremental compilation:

  • ✅ Faster subsequent builds
  • ✅ Only recompiles changed files
  • ✅ Stores build information in .tsbuildinfo file
  • ✅ Recommended by Next.js for better performance

Path Aliases

Default path alias configuration:

// Instead of:
import { Button } from '../../../components/Button';

// You can use:
import { Button } from '@/components/Button';

The @/* alias is pre-configured to point to your project root. You can customize it in your tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Note: Make sure to also configure the same alias in your next.config.js:

// next.config.js
module.exports = {
  webpack: (config) => {
    config.resolve.alias = {
      ...config.resolve.alias,
      '@': path.resolve(__dirname, './src'),
    };
    return config;
  },
};

Or use the built-in Next.js path mapping:

// next.config.js
module.exports = {
  // Next.js 13+ automatically resolves tsconfig paths
};

🎯 When to Use

Use this configuration when you want:

  • ✅ Next.js application development (App Router or Pages Router)
  • ✅ Strict type checking for Next.js code
  • ✅ Incremental builds for faster development
  • ✅ Next.js TypeScript plugin support
  • ✅ Path aliases for cleaner imports
  • ✅ Modern React JSX transform
  • ✅ DOM API type support

For React projects without Next.js, use @jmlweb/tsconfig-react instead.

For non-React TypeScript projects, use @jmlweb/tsconfig-base instead.

🔧 Extending the Configuration

You can extend or override the configuration for your specific needs:

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

Disabling Next.js Plugin

If you need to disable the Next.js plugin:

{
  "extends": "@jmlweb/tsconfig-nextjs",
  "compilerOptions": {
    "plugins": []
  }
}

Customizing Path Aliases

Override the default path alias:

{
  "extends": "@jmlweb/tsconfig-nextjs",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~/*": ["./src/*"]
    }
  }
}

📝 Usage with Scripts

Next.js handles TypeScript compilation automatically. You typically don't need to run tsc manually, but you can add type checking scripts:

{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "typecheck": "tsc --noEmit"
  }
}

Next.js Type Checking

Next.js includes built-in type checking:

  • ✅ Type errors shown during next build
  • ✅ Type errors shown in development mode
  • ✅ IDE integration with TypeScript language server

VS Code Integration

For the best experience in VS Code:

  1. Install the TypeScript extension
  2. Open Command Palette (Ctrl/⌘ + Shift + P)
  3. Select "TypeScript: Select TypeScript Version"
  4. Choose "Use Workspace Version"

This ensures VS Code uses the Next.js TypeScript plugin for enhanced type checking.

📋 Requirements

  • Node.js >= 18.0.0
  • TypeScript >= 5.0.0
  • Next.js >= 13.0.0 (for App Router support)
  • React >= 17.0.0 (for JSX runtime support)

📦 Peer Dependencies

This package requires the following peer dependencies:

  • typescript (>= 5.0.0)
  • next (>= 13.0.0)
  • @jmlweb/tsconfig-react (^1.0.0)

🔗 Related Packages

Internal Packages

External Tools

  • TypeScript - Strongly typed programming language that builds on JavaScript
  • Next.js - The React framework for production
  • React - JavaScript library for building user interfaces
  • Turbopack - Incremental bundler optimized for JavaScript and TypeScript

🔄 Migration Guide

Upgrading to a New Version

Note: If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.

No breaking changes have been introduced yet. This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.

For version history, see the Changelog.

Need Help? If you encounter issues during migration, please open an issue.

📜 Changelog

See CHANGELOG.md for version history and release notes.

📄 License

MIT