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

Is it safe to delete? · Project folders · Updated 21 November 2026. By Mohit Nippanikar, who makes SiftMac.

## The short answer

- **Yes**, with the dev server stopped. `.next` is what Next.js generated from your code: build output, caches and optimized images. None of it is source.
- **What it costs you:** the next `next dev` starts cold, `next build` runs without its cache, and `next start` has nothing to serve until you build again.
- **Does it come back?** Yes, on the next `next dev` or `next build`.
- SiftMac’s verdict: Rebuilds

## 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 production build from `next build`, which `next start` serves.
- `.next/dev`: output of `next dev`. Since Next.js 16, development builds go here, so `next dev` and `next build` can run at the same time.
- `.next/cache`: data kept between builds to make them faster, including Turbopack’s file system cache for builds (`cache/turbopack`, on by default since 16.3) and optimized images (`cache/images`).
- `.next/dev/cache/turbopack`: Turbopack’s cache for the dev server, on by default since 16.1.

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

- `next dev` compiles routes again as you open them, so the first page loads are slow until its cache fills.
- `next build` takes longer without `.next/cache`, which is why CI setups keep that folder between builds.
- `next start` fails until `next build` has run, because it serves the build that lived in `.next`.
- Images are optimized again the first time each is requested.
- Your source, `public` folder, `node_modules` and environment files aren’t touched.

## 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`](https://siftmac.com/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: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [Next.js docs: distDir](https://nextjs.org/docs/app/api-reference/config/next-config-js/distDir)
- [Next.js docs: CI build caching](https://nextjs.org/docs/app/guides/ci-build-caching)
- [Next.js docs: next CLI (dev, build, start)](https://nextjs.org/docs/app/api-reference/cli/next)
- [Next.js docs: Turbopack file system caching](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache)
- [Next.js docs: Image component (image cache, maximumDiskCacheSize)](https://nextjs.org/docs/app/api-reference/components/image)

## Related

- [Is it safe to delete node_modules?](https://siftmac.com/safe-to-delete/node-modules)
- [Is it safe to delete ~/.npm, npm’s cache?](https://siftmac.com/safe-to-delete/npm-cache)
- [Xcode DerivedData, node_modules and Docker: what’s safe to delete on a developer’s Mac](https://siftmac.com/guides/developer-files-on-mac)
- [What fills a web developer’s Mac, from node_modules to Docker](https://siftmac.com/for/web-developers)
- [Developer files: what SiftMac clears, and how it knows it comes back](https://siftmac.com/features/developer-files)

Canonical: https://siftmac.com/safe-to-delete/nextjs-cache
