Skip to content
framework17 active rulesVerified 2026-09-30

Next.js .gitignore Template

Next.js .next build output, cache, and exported static directory. Generated and merged deterministically with upstream GitHub repository patterns to keep your repository clean of package directories, temporary build artifacts, and local environment files.

Interactive Stack Generator

Open in Full Generator
Search for templates
Quick add:
Selected1
Next.js
Selected Templates (1)
.gitignore
### Next.js ###
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
.env
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
17 rules1 template38 lines
Deterministic

Raw Next.js .gitignore

Crawlable upstream source template
nextjs.gitignore37 lines
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
.env
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

Key Pattern Breakdown

Dependencies & Packages

Excludes installed package directories and third-party vendor files that should be restored via package managers.

/node_modules/.pnp.pnp.js

Build & Compilation Artifacts

Ignores compiled binaries, intermediate object files, and build output directories generated during development.

/out//build*.tsbuildinfo

Environment & Secrets

Prevents leaking sensitive local credentials, API keys, database URLs, and environment configuration files.

*.pem.env*.local.env

Cache & Temporary Files

Ignores compiler caches, test runner coverage data, and transient temporary scratch files.

/coveragenpm-debug.log*yarn-debug.log*yarn-error.log*

System & Editor Files

Filters out operating system metadata and workstation-specific editor configuration folders.

.DS_Store

Source & Verification

License:: CC0-1.0

Place this file in the root directory of your project as .gitignore. Changes take effect on newly added or untracked files.