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
title: "Tutorial: Deploy static-rendered Next.js websites on Azure Static Web Apps"
2
+
title: "Deploy static-rendered Next.js websites on Azure Static Web Apps"
3
3
description: "Generate and deploy Next.js dynamic sites with Azure Static Web Apps."
4
4
services: static-web-apps
5
5
author: craigshoemaker
6
6
ms.service: static-web-apps
7
7
ms.topic: tutorial
8
-
ms.date: 03/26/2022
8
+
ms.date: 10/11/2022
9
9
ms.author: cshoe
10
-
ms.custom: devx-track-js
10
+
ms.custom: devx-track-js, engagement-fy23
11
11
---
12
12
13
-
14
13
# Deploy static-rendered Next.js websites on Azure Static Web Apps
15
14
16
-
In this tutorial, you learn to deploy a [Next.js](https://nextjs.org) generated static website to [Azure Static Web Apps](overview.md). For more information about Next.js specifics, see the [starter template's readme](https://github.com/staticwebdev/nextjs-starter#readme).
15
+
In this tutorial, learn to deploy a [Next.js](https://nextjs.org) generated static website to [Azure Static Web Apps](overview.md). For more information about Next.js specifics, see the [starter template readme](https://github.com/staticwebdev/nextjs-starter#readme).
17
16
18
17
## Prerequisites
19
18
20
19
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/).
21
20
- A GitHub account. [Create an account for free](https://github.com/join).
22
21
-[Node.js](https://nodejs.org) installed.
23
22
24
-
## Set up a Next.js app
23
+
## 1. Set up a Next.js app
25
24
26
-
Rather than using the Next.js CLI to create your app, you can use a starter repository. The starter repository contains an existing Next.js application that supports dynamic routes.
25
+
Rather than using the Next.js CLI to create your app, you can use a starter repository. The starter repository contains an existing Next.js app that supports dynamic routes.
27
26
28
27
To begin, create a new repository under your GitHub account from a template repository.
29
28
30
-
1.Navigate to [https://github.com/staticwebdev/nextjs-starter/generate](https://github.com/login?return_to=/staticwebdev/nextjs-starter/generate)
31
-
1. Name the repository **nextjs-starter**
32
-
1. Next, clone the new repo to your machine. Make sure to replace `<YOUR_GITHUB_ACCOUNT_NAME>` with your account name.
29
+
1.Go to [https://github.com/staticwebdev/nextjs-starter/generate](https://github.com/login?return_to=/staticwebdev/nextjs-starter/generate).
30
+
2. Name the repository **nextjs-starter**.
31
+
3. Clone the new repo to your machine. Make sure to replace `<YOUR_GITHUB_ACCOUNT_NAME>` with your account name.
The following steps show how to link your app to Azure Static Web Apps. Once in Azure, you can deploy the application to a production environment.
67
66
68
-
### Create a static app
69
-
70
-
1. Navigate to the [Azure portal](https://portal.azure.com).
67
+
1. Go to the [Azure portal](https://portal.azure.com).
71
68
1. Select **Create a Resource**.
72
69
1. Search for**Static Web Apps**.
73
-
1. Select **Static Web Apps**.
70
+
1. Select **Static Web App**.
74
71
1. Select **Create**.
75
72
1. On the _Basics_ tab, enter the following values.
76
73
@@ -83,7 +80,7 @@ The following steps show how to link your app to Azure Static Web Apps. Once in
83
80
| _Region for Azure Functions API and staging environments_ | Select a region closest to you. |
84
81
| _Source_ |**GitHub**|
85
82
86
-
1. Select **Sign in with GitHub** and authenticate with GitHub.
83
+
1. Select **Sign in with GitHub** and authenticate with GitHub, if prompted.
87
84
88
85
1. Enter the following GitHub values.
89
86
@@ -101,41 +98,50 @@ The following steps show how to link your app to Azure Static Web Apps. Once in
101
98
| _Api location_ | Leave this box empty. |
102
99
| _Output location_ | Enter **out**in the box. |
103
100
104
-
### Review and create
101
+
## 3. Review and create
105
102
106
103
1. Select the **Review + Create** button to verify the details are all correct.
107
104
108
105
1. Select **Create** to start the creation of the App Service Static Web App and provision a GitHub Actions for deployment.
109
106
110
107
1. Once the deployment completes select, **Go to resource**.
111
108
112
-
1. On the _Overview_ window, selectthe*URL* link to open your deployed application.
109
+
2. On the _Overview_ window, selectthe*URL* link to open your deployed app.
113
110
114
111
If the website doesn't load immediately, then the build is still running. Once the workflow is complete, you can refresh the browser to view your web app.
115
112
116
-
To check the status of the Actions workflow, navigate to the Actions dashboard for your repository:
113
+
To check the status of the Actions workflow, go to the *Actions* dashboard for your repository:
Now any changes made to the `main` branch start a new build and deployment of your website.
123
120
124
-
### Sync changes
121
+
## 4. Sync changes
125
122
126
123
When you created the app, Azure Static Web Apps created a GitHub Actions file in your repository. Synchronize with the server by pulling down the latest to your local repository.
127
124
128
125
Return to the terminal and run the following command `git pull origin main`.
129
126
130
127
## Clean up resources
131
128
132
-
If you're not going to continue to use this application, you can delete the Azure Static Web Apps instance through the following steps:
129
+
If you're not going to continue to use this app, you can delete the Azure Static Web Apps instance through the following steps.
133
130
134
131
1. Open the [Azure portal](https://portal.azure.com).
135
-
1. Search for**my-nextjs-group** from the top search bar.
136
-
1. Select on the group name.
137
-
1. Select on the **Delete** button.
138
-
1. Select **Yes** to confirm the delete action.
132
+
2. Search for**my-nextjs-group** from the top search bar.
133
+
3. Select on the group name.
134
+
4. Select on the **Delete** button.
135
+
5. Select **Yes** to confirm the delete action.
136
+
137
+
## Next steps
139
138
140
139
> [!div class="nextstepaction"]
141
140
> [Set up a custom domain](custom-domain.md)
141
+
142
+
## Related articles
143
+
144
+
- [Set up authentication and authorization](authentication-authorization.md)
0 commit comments