Configuring the Build ID

Next.js uses a constant id generated at build time to identify which version of your application is being served. This can cause problems in multi-server deployments when next build is ran on every server. In order to keep a static build id between builds you can provide your own build id.

Open next.config.js and add the generateBuildId function:

  1. module.exports = {
  2. generateBuildId: async () => {
  3. // You can, for example, get the latest git commit hash here
  4. return 'my-build-id'
  5. },
  6. }

Related

[

Introduction to next.config.js

Learn more about the configuration file used by Next.js.]($0b4bd5a3a6817758.md)