github/gitignore · Nextjs.gitignore

Next.js .gitignore Template Explained

Why Nextjs.gitignore ignores .next, out, node_modules, .env files, .vercel, next-env.d.ts and *.pem, and how it differs from the Node template.

Open in generator Open with Node, macOS, VisualStudioCode

Nextjs.gitignore has almost the same contents as the .gitignore created by create-next-app. Most rules start with / and are anchored to the repository root, so if your app lives in a subfolder of a monorepo, adjust the paths or use the Node template as well.

Next.js reads several environment files, including .env, .env.local and .env.development.local. This template excludes both .env and .env*.local.

Rules explained

PatternWhat it ignores and why
/.next//out//buildNext.js buildThe output and cache of next build (.next) and static export output (out). They are recreated during deployment.
/node_modules/.pnp.pnp.jsDependenciesPackage install output and Yarn Plug'n'Play files. They are anchored to the root only, so node_modules in sub-packages is not blocked.
.env.env*.localEnvironment variablesEnvironment files containing secret values. Variables starting with NEXT_PUBLIC_ are embedded in the build output and exposed to the browser, so use secrets only on the server without that prefix.
.vercelnext-env.d.ts*.tsbuildinfoDeployment and generated type filesProject link information created by vercel link, the type declaration file Next.js regenerates during development and builds, and TypeScript incremental build information.
*.pemCertificatesCertificate and private key (.pem) files used for local HTTPS development or integrating with external services. Do not commit private keys.
npm-debug.log*yarn-debug.log*yarn-error.log*/coverage.DS_StoreLogs and otherPackage manager logs, test coverage and macOS Finder files.

Practical notes

Original template

Nextjs.gitignore17 rules
# 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# debugnpm-debug.log*yarn-debug.log*yarn-error.log*# local env files.env*.local.env# vercel.vercel# typescript*.tsbuildinfonext-env.d.ts

Templates from github/gitignore/Nextjs.gitignore @356fd7b (2026-09-11) · CC0-1.0

Often used together

More template explanations