How to control Next.js threads

Sometimes you may need to control how many threads Next.js is using during the Build & Export phase. This may be helpful when troubleshooting the export process, or when you need to reduce the amount of requests going to the Sitecore instance during export (if the Content Sync feature is not enabled).

As of Next.js v10.0, this is still and experimental feature. Set the workerThreads to false and cpus to 1 in next.config.js as shown below. This will ensure that Next.js runs the build and export in a single thread.

Restart the Next.js server after this change.

module.exports = uniformNextConfig({
experimental: {
// This is experimental but can
// be enabled to allow parallel threads
// with nextjs automatic static generation
workerThreads: false,
cpus: 1