.gitignore for React

Ready-to-use .gitignore for React projects โ€” CRA, Next.js, Vite, build output, node_modules, and environment files

Browse all templates

Languages

Frameworks

Game Engines

Platforms

Build Tools

IDEs

OS

Misc

Need more options? Use the full .gitignore generator with 60+ templates and preset combos.

About This Tool

React projects (whether Create React App, Next.js, Vite, or Remix) are built on Node.js and share the same gitignore needs โ€” plus framework-specific build directories like .next, dist, or build. This template combines the Node.js gitignore with Next.js rules and common IDE/OS patterns. It covers npm, yarn, and pnpm, build artifacts, environment files, and everything you need for a clean React repository.

How to Use

1. Review the pre-selected templates (Node.js + Next.js + VS Code + OS) 2. Remove Next.js if you're not using it, or add other templates 3. Click "Copy" or "Download" 4. Place in your project root

Frequently Asked Questions

Should I ignore the build or dist folder?
Yes. Build output (build/, dist/, .next/, out/) is generated from source code and shouldn't be in version control. It can be rebuilt from source at any time.
Do I need different .gitignore for CRA vs Next.js vs Vite?
The Node.js base is the same. The difference is the build directory name: CRA uses build/, Next.js uses .next/ and out/, Vite uses dist/. This template covers all of them.
Should I commit .env.local?
No. Files like .env.local contain secrets specific to your machine. Commit a .env.example file instead that lists the required variables without actual values.

Related Tools