SiftMac
Is it safe to delete? · Project folders · Updated 21 November 2026

Is it safe to delete a Next.js project’s .next folder?

By Mohit Nippanikar, who makes SiftMac

The short answer
On this page
  1. What’s inside .next
  2. Where it is
  3. How big it gets
  4. How to delete it
  5. What happens afterwards
  6. When to keep it
  7. Questions

1. What’s inside .next

.next is Next.js’s build directory, its distDir. The docs say Next.js takes ownership of that directory and will sometimes delete its contents itself. In current versions it holds:

The image cache has a ceiling. Unless you set one, Next.js checks the free disk space once at startup and lets the cache use half of it, then deletes the least recently used images beyond that. images.maximumDiskCacheSize in your Next.js config sets a lower limit, and 0 turns the disk cache off.

2. Where it is

~/Projects/my-site/.next

At the project root, next to next.config.js and package.json, unless distDir names another folder. In a monorepo each Next.js app has its own. To find them with their sizes:

find ~/Projects -type d -name .next -prune -exec du -sh {} + 2>/dev/null | sort -h

3. How big it gets

du -sh .next .next/cache .next/dev 2>/dev/null

The caches are the parts that grow from one run to the next: Turbopack keeps work from earlier builds and dev sessions, and the image cache keeps optimized images up to its limit. The production build itself is replaced by each new build.

4. How to delete it

  1. Stop next dev and next start for that project.
  2. Delete the folder by its full path.
rm -rf ~/Projects/my-site/.next

To keep the last production build and clear only the caches, empty .next/cache instead:

rm -rf ~/Projects/my-site/.next/cache/*

If optimized images are out of date, Next.js’s docs say there’s no way to invalidate that cache yet: change the image’s src, or delete <distDir>/cache/images.

5. What happens afterwards

6. When to keep it

Keep .next on a machine that serves the site with next start, until a new build replaces it. In projects you’ve finished with, clear [node_modules](/safe-to-delete/node-modules) as well; it comes back with an install.

Questions

Is it safe to delete .next while next dev is running?

Stop it first: the dev server writes to .next/dev as you work. Delete the folder, start next dev again, and it rebuilds what it needs.

Why is my .next folder so big?

Look in .next/cache and .next/dev/cache first. Turbopack’s file system caches live there, and so does the optimized image cache, which by default may use up to half the free space Next.js saw when it started. images.maximumDiskCacheSize caps it.

Is .next/cache safe to delete on its own?

Yes. It only speeds up builds and image serving; the next build or request recreates what it needs, and the production build next to it stays usable.

Should CI keep .next/cache between builds?

Next.js recommends it: persisting .next/cache is what makes repeat builds faster, and a CI that doesn’t keep it may show a No Cache Detected message.

How SiftMac handles it. Its Developer files category lists .next folders that sit next to a package.json, in projects whose own files haven’t changed for 1, 3 or 6 months, as a web build cache, along with .nuxt, .svelte-kit, .turbo, .parcel-cache and .angular folders. None is ticked until you tick it.

Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works