.gitignore for Next.js

17 ignore rules for Next.js, ready to copy into your repository.

React framework for production

The complete .gitignore for Next.js

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2025-08-02 07:29:09 UTC
# Technologies: Next.js

### Next.js ###
# macOS folder settings (Desktop Services Store)
.DS_Store
/node_modules
/.pnp
.pnp.js
/build
/coverage
/.next/
/out/
# Privacy Enhanced Mail certificate
*.pem
# npm debug logs
npm-debug.log*
# Yarn debug logs
yarn-debug.log*
# Yarn error logs
yarn-error.log*
.env*.local
# Environment variables
.env
.vercel
# TypeScript build info
*.tsbuildinfo
next-env.d.ts

What these Next.js rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

General

Pattern What it ignores
.DS_Store macOS folder settings (Desktop Services Store)
/node_modules dependencies
/.pnp General
.pnp.js General
/build General
/coverage testing
/.next/ next.js
/out/ General
*.pem Privacy Enhanced Mail certificate
npm-debug.log* npm debug logs
yarn-debug.log* Yarn debug logs
yarn-error.log* Yarn error logs
.env*.local local env files
.env Environment variables
.vercel vercel
*.tsbuildinfo TypeScript build info
next-env.d.ts General

How to use this .gitignore for Next.js

  1. Copy the Next.js rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Framework .gitignore templates

See every Framework template