c5eb535229
* Expand on the docs for the serverless target * Added catch all routes to API docs * Added caveat for catch all routes * Added link to Rauch's post about serverless * Add mention of `lang` * Add create-next-app to docs * Updated dynamic import examples to be more descriptive * Even better * Clarify valid catch all routes * Removed unexpected word * Apply suggestions from Joe Co-Authored-By: Joe Haddad <joe.haddad@zeit.co> * Keep #setup Co-Authored-By: Joe Haddad <joe.haddad@zeit.co> * Updated docs for the serverless target * Apply suggestions from code review Co-Authored-By: Shu Uesugi <shu@chibicode.com> * Update docs/getting-started.md Co-Authored-By: Shu Uesugi <shu@chibicode.com> * Added suggestion from chibicode Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Shu Uesugi <shu@chibicode.com>
47 lines
1.8 KiB
Markdown
47 lines
1.8 KiB
Markdown
---
|
|
description: Learn more about the build targets used by Next.js, which decide the way your application is built and run.
|
|
---
|
|
|
|
# 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](#serverless-target). The `serverless` target enforces [additional constraints](https://rauchg.com/2020/2019-in-review#serverless-upgrades-itself) to keep you in the [Pit of Success](https://blog.codinghorror.com/falling-into-the-pit-of-success/).
|
|
|
|
This target is compatible with both `next start` and [custom server](/docs/advanced-features/custom-server.md) 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 [ZEIT Now](https://zeit.co) will automatically enable this target. You do not need to opt-into it yourself, but you can.
|
|
|
|
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 [ZEIT Now](https://zeit.co)) — you cannot use the custom server API.
|
|
|
|
To opt-into this target, set the following configuration in your `next.config.js`:
|
|
|
|
```js
|
|
module.exports = {
|
|
target: 'serverless',
|
|
}
|
|
```
|
|
|
|
## Related
|
|
|
|
<div class="card">
|
|
<a href="/docs/api-reference/next.config.js/introduction.md">
|
|
<b>Introduction to next.config.js:</b>
|
|
<small>Learn more about the configuration file used by Next.js.</small>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<a href="/docs/deployment.md">
|
|
<b>Deployment:</b>
|
|
<small>Compile and deploy your Next.js app to production.</small>
|
|
</a>
|
|
</div>
|