Skip to content

Commit 9a9c0d2

Browse files
chibicodeLuis Alvarez D.leo
authored
Update deploy doc to surface ZEIT Now / DPS (vercel#10412)
* Update deploy docs to surface ZEIT Now / DPS * Undo removal of deployment section from static export * Update description slightly * Wordsmith * Wordsmith * Capitalize Serverless Functions * Wordsmith * Update docs/deployment.md Co-Authored-By: Luis Alvarez D. <luis@zeit.co> * Update docs/deployment.md Co-Authored-By: Luis Alvarez D. <luis@zeit.co> * Update deployment.md * Update deployment.md * Update docs/deployment.md Co-Authored-By: Leo Lamprecht <mindrun@icloud.com> * Update docs/deployment.md Co-Authored-By: Leo Lamprecht <mindrun@icloud.com> * Update docs/deployment.md Co-Authored-By: Leo Lamprecht <mindrun@icloud.com> * Update docs/deployment.md Co-Authored-By: Leo Lamprecht <mindrun@icloud.com> * Update "develop" section * Wordsmith Co-authored-by: Luis Alvarez D. <luis@zeit.co> Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
1 parent 79fb13e commit 9a9c0d2

File tree

1 file changed

+45
-73
lines changed

1 file changed

+45
-73
lines changed

docs/deployment.md

Lines changed: 45 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,77 @@
11
---
2-
description: Compile and deploy your Next.js app to production with ZEIT Now and other hosting alternatives.
2+
description: Deploy your Next.js app to production with ZEIT Now and other hosting options.
33
---
44

55
# Deployment
66

7-
To go to production Next.js has a `next build` command. When run, it will compile your project and automatically apply numerous optimizations.
7+
## ZEIT Now (Recommended)
88

9-
## Prepare your package.json
9+
The easiest way to deploy Next.js to production is to use the **[ZEIT Now platform](https://zeit.co)** from the creators of Next.js. [ZEIT Now](https://zeit.co) is an all-in-one platform with Global CDN supporting static & JAMstack deployment and Serverless Functions.
1010

11-
Ensure your `package.json` has the `"build"` and `"start"` scripts:
12-
13-
```json
14-
{
15-
"scripts": {
16-
"dev": "next",
17-
"build": "next build",
18-
"start": "next start"
19-
}
20-
}
21-
```
22-
23-
In the case that you'd want to do a [full static export](/docs/advanced-features/static-html-export.md) of the Next.js application add `next export` to the `"build"` script:
24-
25-
```json
26-
{
27-
"scripts": {
28-
"dev": "next",
29-
"build": "next build && next export",
30-
"start": "next start"
31-
}
32-
}
33-
```
11+
### Getting started
3412

35-
## ZEIT Now
13+
If you haven’t already done so, push your Next.js app to a Git provider of your choice: [GitHub](http://github.com/), [GitLab](https://gitlab.com/), or [BitBucket](https://bitbucket.org/). Your repository can be private or public.
3614

37-
The easiest way to deploy Next.js to production is using the [ZEIT Now platform](https://zeit.co) from the creators of Next.js.
15+
Then, follow these steps:
3816

39-
### Preview deployments
17+
1. [Sign up to ZEIT Now](https://zeit.co/signup) (no credit card is required).
18+
2. After signing up, you’ll arrive on the [“Create a new project”](https://zeit.co/new) page. Under “From your existing code”, choose the Git provider you use and set up an integration. (Instructions: [GitHub](https://zeit.co/docs/v2/git-integrations/zeit-now-for-github) / [GitLab](https://zeit.co/docs/v2/git-integrations/zeit-now-for-gitlab) / [BitBucket](https://zeit.co/docs/v2/git-integrations/zeit-now-for-bitbucket)).
19+
3. Once that’s set up, click “New Project From …” and import your Next.js app. It auto-detects that your app is using Next.js and sets up the build configuration for you. No need to change anything — everything just works!
20+
4. After importing, it’ll deploy your Next.js app and provide you with a deployment URL. Click “Visit” to see your app in production.
4021

41-
ZEIT Now integrates directly with GitHub, GitLab, and Bitbucket to give you a unique shareable url for every commit and every pull request. This url can be shared with customers and can be used to run integration tests against.
22+
Congratulations! You’ve just deployed your Next.js app! If you have questions, take a look at the [ZEIT Now documentation](https://zeit.co/docs).
4223

43-
### Hybrid Next.js
24+
> If you’re using a [custom server](/docs/advanced-features/custom-server.md) (which we don’t recommend), consider [other hosting options](#other-hosting-options).
4425
45-
The [hybrid pages](/docs/basic-features/pages.md) approach is fully supported out of the box. Meaning that every page can either use [Static Generation](/docs/basic-features/pages.md#static-generation) or [Server-Side Rendering](/docs/basic-features/pages.md#server-side-rendering).
26+
### DPS: Develop, Preview, Ship
4627

47-
In case of [Static Generation](/docs/basic-features/pages.md#static-generation) the page will automatically be served from the ZEIT Now Smart CDN.
28+
Let’s talk about the workflow we recommend using. [ZEIT Now](https://zeit.co) supports what we call the **DPS** workflow: **D**evelop, **P**review, and **S**hip:
4829

49-
When the page is using [Server-Side Rendering](/docs/basic-features/pages.md#server-side-rendering) it will become an isolated serverless function automatically. This allows the page rendering to scale automatically and be independent—errors on one page won't affect another.
30+
- **Develop:** Write code in Next.js. Keep the development server running and take advantage of its hot code reloading feature.
31+
- **Preview:** Every time you push changes to a branch on GitHub / GitLab / BitBucket, ZEIT Now automatically creates a new deployment with a unique URL. You can view them on GitHub when you open a pull request, or under “Preview Deployments” on your project page on ZEIT Now. [Learn more about it here](https://zeit.co/features/deployment-previews).
32+
- **Ship:** When you’re ready to ship, merge the pull request to your default branch (e.g. `master`). ZEIT Now will automatically create a production deployment.
5033

51-
API routes will also become separate serverless functions that execute and scale separately from each other.
34+
By using the DPS workflow, in addition to doing _code reviews_, you can do _deployment previews_. Each deployment creates a unique URL that can be shared or used for integration tests.
5235

53-
### CDN + HTTPS by default
36+
### Optimized for Next.js
5437

55-
Assets (JavaScript, CSS, images, fonts etc) and Statically Generated pages are automatically served through the ZEIT Now Smart CDN, ensuring these are always served close to your users.
38+
[ZEIT Now](https://zeit.co) is made by the creators of Next.js and has first-class support for Next.js.
5639

57-
HTTPS is enabled by default and doesn't require extra configuration.
40+
For example, the [hybrid pages](/docs/basic-features/pages.md) approach is fully supported out of the box.
5841

59-
### Getting started
42+
- Every page can either use [Static Generation](/docs/basic-features/pages.md#static-generation) or [Server-Side Rendering](/docs/basic-features/pages.md#server-side-rendering).
43+
- Pages that use [Static Generation](/docs/basic-features/pages.md#static-generation) and assets (JS, CSS, images, fonts, etc) will automatically be served from the [ZEIT Now Smart CDN](https://zeit.co/smart-cdn), which is blazingly fast.
44+
- Pages that use [Server-Side Rendering](/docs/basic-features/pages.md#server-side-rendering) and [API routes](/docs/api-routes/introduction.md) will automatically become isolated Serverless Functions. This allows page rendering and API requests to scale infinitely.
6045

61-
#### From a git repository
46+
### Custom Domains, Environment Variables, Automatic HTTPS, and more
6247

63-
You can link your project in [GitHub](https://zeit.co/new), [GitLab](https://zeit.co/new), or [Bitbucket](https://zeit.co/new) through the [web interface](https://zeit.co/new). This will automatically set up deployment previews for pull requests and commits. To learn more about ZEIT Now’s Git integration, take a look at [our documentation here](https://zeit.co/docs/v2/git-integration/).
48+
- **Custom Domains:** Once deployed on [ZEIT Now](https://zeit.co), you can assign a custom domain to your Next.js app. Take a look at [our documentation here](https://zeit.co/docs/v2/custom-domains).
49+
- **Environment Variables:** You can also set environment variables on ZEIT Now. Take a look at [our documentation here](https://zeit.co/docs/v2/build-step#using-environment-variables-and-secrets). You can then [use those environment variables](/docs/api-reference/next.config.js/environment-variables.md) in your Next.js app.
50+
- **Automatic HTTPS:** HTTPS is enabled by default (including custom domains) and doesn't require extra configuration. We auto-renew SSL certificates.
51+
- **More:** [Read our documentation](https://zeit.co/docs) to learn more about the ZEIT Now platform.
6452

65-
#### Through the ZEIT Now CLI
53+
## Other hosting options
6654

67-
You can install [Now CLI](https://zeit.co/download) from either npm or Yarn. Using npm, run the following command from your terminal:
55+
### Node.js Server
6856

69-
```bash
70-
npm install -g now
71-
```
57+
Next.js can be deployed to any hosting provider that supports Node.js. This is the approach you should take if you’re using a [custom server](/docs/advanced-features/custom-server.md).
7258

73-
You can deploy your application by running the following command in the root of the project directory:
59+
Make sure your `package.json` has the `"build"` and `"start"` scripts:
7460

75-
```bash
76-
now
61+
```json
62+
{
63+
"scripts": {
64+
"dev": "next",
65+
"build": "next build",
66+
"start": "next start"
67+
}
68+
}
7769
```
7870

79-
You will receive a unique link similar to the following: https://your-project.username.now.sh.
80-
81-
#### Custom domains
82-
83-
Once deployed on ZEIT Now, your projects can be assigned to a custom domain of your choice. To learn more, take a look at [our documentation here](https://zeit.co/docs/v2/custom-domains/).
84-
85-
## Self hosting
86-
87-
Next.js can be deployed to any hosting provider that supports Node.js. In order to self-host there are two commands: `next build` and `next start`.
88-
89-
`next build` builds the production application in the `.next` folder.
90-
91-
`next start` starts a Node.js server that supports [hybrid pages](/docs/basic-features/pages.md), serving both statically generated and server-side rendered pages.
92-
93-
Generally you'll have to follow these steps to deploy to production:
71+
`next build` builds the production application in the `.next` folder. After building, `next start` starts a Node.js server that supports [hybrid pages](/docs/basic-features/pages.md), serving both statically generated and server-side rendered pages.
9472

95-
- Run `npm install`
96-
- Run `npm run build` (runs `next build`)
97-
- Potentially copy the `.next`, `node_modules`, and `package.json` to your server.
98-
- Run `npm run start` (runs `next start`) on the server
73+
### Static HTML Export
9974

100-
In case you're doing a full static export using `next export` the steps are slightly different and don't involve using `next start`:
75+
If you’d like to do a static HTML export of your Next.js app, follow the directions on [our documentation](/docs/advanced-features/static-html-export.md). By default, `next export` will generate an `out` directory, which can be served by any static hosting service or CDN.
10176

102-
- Run `npm install`
103-
- Run `npm run build` (runs `next build && next export`)
104-
- A `out` directory is generated by `next export`
105-
- Copy the `out` directory to the server and make sure it's served by your server
77+
> We strongly recommend using [ZEIT Now](https://zeit.co/) even if your Next.js app is fully static. [ZEIT Now](https://zeit.co/) is optimized to make static Next.js apps blazingly fast. `next export` works with Zero Config deployments on ZEIT Now.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy