You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting from Nx 11, your Next.js application should already be ready for deployment to Vercel.
4
+
5
+
## Configure your Vercel project's settings appropriately
6
+
7
+
### New Vercel project
8
+
9
+
1. If you are "importing" your Nx workspace's repository for the first time, make sure you do _not_ choose a root directory as part of the repo selection process (therefore leaving it to be the root of the full repo/workspace)
10
+
2. Ensure the Next.js "Framework Preset" is selected
11
+
3. Expand the "Build and Output Settings" and toggle the override switch for the build command. For example, for an application named `tuskdesk` the value will look like this:
12
+
13
+
```bash
14
+
npx nx build tuskdesk --prod
15
+
```
16
+
17
+
4. Toggle the override switch for the output directory. Point it to the `.next` directory inside the built app:
18
+
19
+
```bash
20
+
dist/apps/tuskdesk/.next
21
+
```
22
+
23
+
Therefore, our full configuration (based on a repo called "nx-workspace" and a project called "tuskdesk") will look like this:
24
+
25
+

26
+
27
+
### Existing Vercel project
28
+
29
+
If you have an existing project on Vercel then the exact same guidance applies as for the section above, it's just that you will need to update the project's existing settings.
30
+
31
+
When everything is updated appropriately, for our `tuskdesk` example we would see the following in our "General" settings UI:
32
+
33
+

34
+
35
+
Naturally, you can continue on and set any additional Environment Variables etc that may be appropriate for your projects, but we have now covered the key points needed to deploy Next.js projects from Nx workspaces on Vercel!
Copy file name to clipboardExpand all lines: docs/react/guides/nextjs.md
+3-35Lines changed: 3 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,43 +236,11 @@ Without Nx, creating a new shared library can take from several hours or even we
236
236
237
237
You can share React components between multiple Next.js applications. You can also share web components between Next.js and plain React applications. You can even share code between the backend and the frontend. All can be done without any unnecessary ceremony.
238
238
239
-
## Deploying to Vercel
239
+
## Deploying your Next.js Application
240
240
241
-
You may know that the company behind Next.js, [Vercel](https://vercel.com), has a great hosting platform offering that is developed in tandem with Next.js itself to offer a great overall developer and user experience.
241
+
Once you are ready to deploy your Next.js application, you have absolute freedom to choose any hosting provider that fits your needs.
242
242
243
-
Starting from Nx 11, your Next.js application should already be ready for deployment to Vercel.
244
-
245
-
### Configure your Vercel project's settings appropriately
246
-
247
-
#### New Vercel project
248
-
249
-
1. If you are "importing" your Nx workspace's repository for the first time, make sure you do _not_ choose a root directory as part of the repo selection process (therefore leaving it to be the root of the full repo/workspace)
250
-
2. Ensure the Next.js "Framework Preset" is selected
251
-
3. Expand the "Build and Output Settings" and toggle the override switch for the build command. For our `tuskdesk` project the value will look like this:
252
-
253
-
```bash
254
-
npx nx build tuskdesk --prod
255
-
```
256
-
257
-
4. Toggle the override switch for the output directory. Point it to the `.next` directory inside the built app:
258
-
259
-
```bash
260
-
dist/apps/tuskdesk/.next
261
-
```
262
-
263
-
Therefore, our full configuration (based on a repo called "nx-workspace" and a project called "tuskdesk") will look like this:
264
-
265
-

266
-
267
-
#### Existing Vercel project
268
-
269
-
If you have an existing project on Vercel then the exact same guidance applies as for the section above, it's just that you will need to update the project's existing settings.
270
-
271
-
When everything is updated appropriately, for our `tuskdesk` example we would see the following in our "General" settings UI:
272
-
273
-

274
-
275
-
Naturally, you can continue on and set any additional Environment Variables etc that may be appropriate for your projects, but we have now covered the key points needed to deploy Next.js projects from Nx workspaces on Vercel!
243
+
You may know that the company behind Next.js, Vercel, has a great hosting platform offering that is developed in tandem with Next.js itself to offer a great overall developer and user experience. We have detailed [how to deploy your Next.js application to Vercel in a separate guide](/react/guides/deploy-nextjs-to-vercel).
0 commit comments