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: docs/1.docs/4.renderer.md
+107-2Lines changed: 107 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,111 @@ If you define a catch-all route (`[...].ts`) in your routes, Nitro will warn you
174
174
175
175
:read-more{to="/docs/lifecycle"title="Lifecycle"}
176
176
177
+
## Server-Side Rendering (SSR)
178
+
179
+
Nitro supports full server-side rendering through Vite's [environment API](https://vite.dev/guide/api-environment). With SSR, Nitro renders your application to HTML on the server, sends it to the browser, and the client hydrates the page to make it interactive.
180
+
181
+
This requires two entry files:
182
+
183
+
-**Server entry** (`entry-server`) — renders the app to HTML on the server.
184
+
-**Client entry** (`entry-client`) — hydrates the server-rendered HTML in the browser.
185
+
186
+
### Auto-detected entry points
187
+
188
+
Nitro automatically detects `entry-server` and `entry-client` files in your project's `app/`, `src/`, or root directory. No Vite configuration is needed when you follow this convention.
189
+
190
+
```
191
+
app/
192
+
entry-server.ts ← auto-detected as SSR entry
193
+
entry-client.ts ← auto-detected as client entry
194
+
routes/
195
+
api/hello.ts
196
+
```
197
+
198
+
::tip
199
+
When entry files are detected, Nitro logs the paths in the terminal:
The server entry must export an object with a `fetch` method that receives a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) and returns a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response):
The `?assets=client` suffix tells Nitro to collect assets from the client environment, while `?assets=ssr` collects assets from the SSR environment (such as CSS imported only in server components). The `merge()` method combines them into a single manifest with:
266
+
267
+
-`assets.entry` — the client entry script URL
268
+
-`assets.css` — an array of stylesheet attributes (`{ href }`)
269
+
-`assets.js` — an array of module preload attributes (`{ href }`)
0 commit comments