distDir
Set a custom build directory to use instead of the default .next directory.
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:
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 error when distDir resolves outside
the application and workspace, or when it is the application directory itself or one of
its ancestors.