Skip to content

Commit bf831e9

Browse files
update steps
1 parent 8723866 commit bf831e9

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

articles/static-web-apps/deploy-nextjs-hybrid.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ Once GitHub Actions workflow is complete, you can select the URL link to open th
112112

113113
## Set up your Next.js project locally to make changes
114114

115-
1. Clone the new repo to your machine. Make sure to replace <YOUR_GITHUB_ACCOUNT_NAME> with your account name.
115+
1. Clone the new repo to your machine. Make sure to replace <GITHUB_ACCOUNT_NAME> with your account name.
116116

117117
```bash
118-
git clone http://github.com/<YOUR_GITHUB_ACCOUNT_NAME>/my-first-static-web-app
118+
git clone http://github.com/<GITHUB_ACCOUNT_NAME>/my-first-static-web-app
119119
```
120120

121121
1. Open the project in Visual Studio Code or your preferred code editor.
@@ -128,7 +128,7 @@ Once GitHub Actions workflow is complete, you can select the URL link to open th
128128

129129
To add server-rendered data in your Next.js project using the App Router, edit a Next.js component to add a server-side operation to render data in the component. By default, Next.js components are [Server Components](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating) that can be server-rendered.
130130

131-
1. Open the `app/page.tsx` file and add an operation that sets the value of a variable, which is computed server-side. Examples include fetching data or other server operations.
131+
1. Open the `app/page.tsx` file and add an operation that sets the value of a server-side computed variable. Examples include fetching data or other server operations.
132132

133133
```ts
134134
export default function Home() {
@@ -157,7 +157,7 @@ To add server-rendered data in your Next.js project using the App Router, edit a
157157
>[!NOTE]
158158
>This example forces dynamic rendering of this component to demonstrate server-rendering of the server's current time. The App Router model of Next.js recommends caching individual data requests to optimize the performance of your Next.js app. Read more on [data fetching and caching in Next.js](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating).
159159
160-
1. Update the `Home` component in _app/pages.tsx_ to render the server-side data.
160+
1. Update the `Home` component in _app/pages.tsx_ to render the server-side data.
161161
162162
```ts
163163
import { unstable_noStore as noStore } from 'next/cache';
@@ -169,8 +169,7 @@ To add server-rendered data in your Next.js project using the App Router, edit a
169169
return(
170170
<main className="flex min-h-screen flex-col items-center justify-between p-24">
171171
<div>
172-
This is a Next.js application hosted on Azure Static Web Apps with
173-
hybrid rendering. The time on the server is <strong>{timeOnServer}</strong>.
172+
This is a Next.js application hosted on Azure Static Web Apps with hybrid rendering. The time on the server is <strong>{timeOnServer}</strong>.
174173
</div>
175174
</main>
176175
);
@@ -179,11 +178,12 @@ To add server-rendered data in your Next.js project using the App Router, edit a
179178
180179
## Adding an API route
181180
182-
In addition to Server Components, Next.js provides [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers) you can use to create API routes to your Next.js application. These APIs can be fetched in [Client Components](https://nextjs.org/docs/app/building-your-application/rendering/client-components).
181+
In addition to Server Components, Next.js provides [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers) you can use to create API routes to your Next.js application. You can fetch these APIs in [Client Components](https://nextjs.org/docs/app/building-your-application/rendering/client-components).
183182
184183
Begin by adding an API route.
185184
186185
1. Create a new file at `app/api/currentTime/route.tsx`. This file holds the Route Handler for the new API endpoint.
186+
187187
1. Add a handler function to return data from the API.
188188
189189
```ts
@@ -246,8 +246,7 @@ This Client Component fetches the API with a `useEffect` React hook to render th
246246
return(
247247
<main className="flex min-h-screen flex-col items-center justify-between p-24">
248248
<div>
249-
This is a Next.js application hosted on Azure Static Web Apps with
250-
hybrid rendering. The time on the server is <strong>{timeOnServer}</strong>.
249+
This is a Next.js application hosted on Azure Static Web Apps with hybrid rendering. The time on the server is <strong>{timeOnServer}</strong>.
251250
</div>
252251
<CurrentTimeFromAPI />
253252
</main>
@@ -261,7 +260,7 @@ This Client Component fetches the API with a `useEffect` React hook to render th
261260
262261
## Configure the runtime version for Next.js
263262
264-
Certain Next.js versions require specific Node.js versions. To configure a specific Node version, you can set the 'engines' property of your `package.json` file to designate a version.
263+
Certain Next.js versions require specific Node.js versions. To configure a specific Node version, you can set the `engines` property of your `package.json` file to designate a version.
265264
266265
```json
267266
{
@@ -274,7 +273,7 @@ Certain Next.js versions require specific Node.js versions. To configure a speci
274273
275274
## Set environment variables for Next.js
276275
277-
Next.js uses environment variables at build time and at request time, to support both static page generation and dynamic page generation with server-side rendering. Therefore, set environment variables both within the build and deploy task, and in the _Environment variables_ of your Azure Static Web Apps resource.
276+
Next.js uses environment variables at build time and at request time, to support both static page generation and dynamic page generation with server-side rendering. Therefore, set environment variables both within the build and deploy task, and in the _Environment variables_ of your Azure Static Web Apps resource.
278277
279278
```yml
280279
...
@@ -327,7 +326,7 @@ Next, configure the `build` command in the `package.json` file in order to copy
327326
328327
## Configure routing and middleware for deployment
329328
330-
Your Next.js project can be configured to have custom handling of routes with redirects, rewrites, and middleware. These handlers are commonly used for authentication, personalization, routing, and internationalization. Custom handling affects the default routing of your Next.js site and the configuration must be compatible with hosting on Static Web Apps.
329+
You can configure your Next.js project handle of routes with custom redirects, rewrites, and middleware. These handlers are commonly used for authentication, personalization, routing, and internationalization. Custom handling affects the default routing of your Next.js site and the configuration must be compatible with hosting on Static Web Apps.
331330
332331
Static Web Apps validates that your Next.js site is successfully deployed by adding a page to your site at build time. The page is named `public/.swa/health.html`, and Static Web Apps verifies the successful startup and deployment of your site by navigating to `/.swa/health.html` and verifying a successful response. Middleware and custom routing, which includes redirects and rewrites, can affect the access of the `/.swa/health.html` path, which can prevent Static Web Apps' deployment validation. To configure middleware and routing for a successful deployment to Static Web Apps, follow these steps:
333332
@@ -345,7 +344,7 @@ Static Web Apps validates that your Next.js site is successfully deployed by add
345344
}
346345
```
347346
348-
1. Configure your redirects in `next.config.js` to exclude routes starting with `.swa`
347+
1. Configure your redirects in `next.config.js` to exclude routes starting with `.swa`.
349348
350349
```js
351350
module.exports = {
@@ -361,7 +360,7 @@ Static Web Apps validates that your Next.js site is successfully deployed by add
361360
};
362361
```
363362
364-
1. Configure your rewrite rules in `next.config.js` to exclude routes starting with `.swa`
363+
1. Configure your rewrite rules in `next.config.js` to exclude routes starting with `.swa`.
365364
366365
```js
367366
module.exports = {

includes/static-web-apps/static-web-apps-nextjs-backends.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ ms.date: 06/11/2024
66
ms.author: cshoe
77
---
88

9-
A managed backed is automatically available for every hybrid Next.js deployment. However, you can fine tune performance and take more control of the backend by assigning a custom backend to your site. The following steps show you how to associate a custom backend to your site.
9+
A managed backed is automatically available for every hybrid Next.js deployment in all plans. However, you can fine- tune performance and take more control of the backend by assigning a custom backend to your site. If you switch between a managed backend to a linked backend, your site experiences no downtime.
10+
11+
The following steps show you how to associate a custom backend to your Standard plan and above static web apps.
12+
13+
> [!NOTE]
14+
> Linked backends are only available for sites using the Standard plan or above.
1015
1116
1. Go to your static web app in the Azure portal.
1217

1318
1. Select **Settings** and then **APIs** from the side menu.
1419

15-
1. Under the *Backend Resource Name*, select the link labeled **(managed)**.
16-
1720
1. Select **Configure linked backend**.
1821

1922
1. Either create a new App Service Plan or select an existing App Service Plan.
2023

21-
Your selected App Service Plan must use at least an **S1** SKU.
24+
Your selected App Service Plan must use at least an **S1** SKU.
25+
26+
1. Click **Link**.

0 commit comments

Comments
 (0)