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
Copy file name to clipboardExpand all lines: articles/static-web-apps/deploy-nextjs-hybrid.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,10 @@ Once GitHub Actions workflow is complete, you can select the URL link to open th
119
119
120
120
1. Open the project in Visual Studio Code or your preferred code editor.
121
121
122
+
## Set up server side rendering
123
+
124
+
[!INCLUDE [Server side rendering](../../includes/static-web-apps/static-web-apps-nextjs-backends.md)]
125
+
122
126
## Add Server-Rendered data with a Server Component
123
127
124
128
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.
@@ -135,7 +139,7 @@ To add server-rendered data in your Next.js project using the App Router, edit a
135
139
```
136
140
137
141
1. Import `unstable_noStore` from `next/cache` and call it within the `Home` component to ensure the route is dynamically rendered.
138
-
142
+
139
143
```ts
140
144
import { unstable_noStore as noStore } from 'next/cache';
141
145
@@ -196,6 +200,7 @@ Begin by adding an API route.
196
200
```
197
201
198
202
1. Create a new file at `app/components/CurrentTimeFromAPI.tsx`. This component creates a container for the Client Component that fetches the API from the browser.
203
+
199
204
1. Add a client component that fetches the API in this file.
200
205
201
206
```ts
@@ -248,7 +253,7 @@ This Client Component fetches the API with a `useEffect` React hook to render th
248
253
);
249
254
}
250
255
```
251
-
256
+
252
257
1. The result from the API route is displayed on the page.
253
258
254
259
:::image type="content" source="media/deploy-nextjs/nextjs-13-home-display.png" alt-text="Screenshot showing the display the output from the API route.":::
@@ -298,6 +303,7 @@ When your application size exceeds 250 MB, the Next.js [Output File Tracing](htt
298
303
Output File Tracing creates a compressed version of the whole application with necessary package dependencies. This package is built into a folder named _.next/standalone_. With this package, your app can deploy on its own without _node_modules_ dependencies.
299
304
300
305
In order to enable the `standalone` feature, add the following property to your `next.config.js`:
Next.js applications that use server-side rendering require a dedicated Azure App Service as the deployment destination for the backend of the application. Once you have this hosting plan, you can link your static web app to the App Service plan.
10
+
11
+
When you link the backend resource to your Next.js app, server-side requests are served from the backend server.
12
+
13
+
Use the following steps to link your App Service plan to your static web app:
14
+
15
+
1. Create an Azure App Service under the **S1** plan.
16
+
17
+
1. Go to your static web app in the Azure portal.
18
+
19
+
1. In the *Settings* section, select **APIs**.
20
+
21
+
1. Append the following text to the end of the URL in your browser's location:
22
+
23
+
```text
24
+
exp.AzurePortal_enable-nextjs=true
25
+
```
26
+
27
+
Once you complete these steps, you can link your static web app to your App Service plan using this screen.
0 commit comments