Join GitHub today
Deploying a Next.js app is pretty simple. You could deploy it almost anywhere Node.js is supported.
Deploying Multiple Instances
It's pretty common to use multiple instances of your app if it's getting more traffic. Then make sure to build your app with
next build once and start multiple instances with
Otherwise, it's possible for your app to reload when your users navigate between pages.
We generate a unique
BUILD_ID for each time when you run
next build. We use that id to detect new versions from the client side. If the client side app detects a new
BUILD_ID it'll reload the page. With that, your users will use the latest version of your app always.
Since now you've multiple
BUILD_IDs in different instances, our client side app thinks it's a new version and it tries to reload the app.
The best fix is to build the app once with
next build and run many instances. Sometimes this is not possible. Then in those cases, you could override the
BUILD_ID with your own id. Here's how to do it.
- Build your app with
- Make sure that id is unique across all the instances. (For an example, GIT commit id)
Running Different Versions
Specially with rolling-deployment techniques, it's possible to have two versions of your app running behind a single domain name.