---
title: distDir
description: Set a custom build directory to use instead of the default .next directory.
url: "https://nextjs.org/docs/app/api-reference/config/next-config-js/distDir"
docs_index: /docs/llms.txt
version: 16.4.0
lastUpdated: 2026-09-23
prerequisites:
  - "Configuration: /docs/app/api-reference/config"
  - "next.config.js: /docs/app/api-reference/config/next-config-js"
---


> For an index of all Next.js documentation, see [/docs/llms.txt](/docs/llms.txt).
You can specify a name to use for a custom build directory to use instead of `.next`.

Open `next.config.js` and add the `distDir` config:

```js filename="next.config.js"
module.exports = {
  distDir: 'build',
}
```

Now if you run `next build` Next.js will use `build` instead of the default `.next` folder.

> **Good To Know:** Next.js takes ownership of `distDir` and will sometimes delete its contents. Point it at a directory used only by Next.js.

`distDir` is resolved relative to the directory holding your `next.config.js`, and may
point to a dedicated directory inside the workspace that contains it. In a monorepo, an
application at `apps/web` can build into `../.next`.

To protect against data loss, Next.js refuses to use the directory and fails with an
[Invalid distDir](/docs/messages/invalid-dist-dir) error when `distDir` resolves outside
the application and workspace, or when it is the application directory itself or one of
its ancestors.
---

For a semantic overview of all documentation, see [/docs/sitemap.md](/docs/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)