Build Target
Next.js supports various build targets, each changing the way your application is built and run. We’ll explain each of the targets below.
server
target
This is the default target, however, we highly recommend the
serverless
target. Theserverless
target enforces additional constraints to keep you in the Pit of Success.
This target is compatible with both next start
and custom server setups (it’s mandatory for a custom server).
Your application will be built and deployed as a monolith. This is the default target and no action is required on your part to opt-in.
serverless
target
Deployments to Vercel will automatically enable this target. You should not opt-into it yourself.
This target will output independent pages that don’t require a monolithic server.
It’s only compatible with next start
or Serverless deployment platforms (like Vercel) — you cannot use the custom server API.
To opt-into this target, set the following configuration in your next.config.js
:
module.exports = {
target: 'serverless',
}
Related
[
Introduction to next.config.js
Learn more about the configuration file used by Next.js.]($0b4bd5a3a6817758.md)
[
Deployment
Compile and deploy your Next.js app to production.]($6f0bc6b9cdbb6ac8.md)