UNPKG

next

Version:

The React Framework

30 lines (21 loc) • 1.32 kB
--- title: distDir description: Set a custom build directory to use instead of the default .next directory. --- {/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} 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.