Every route in a Nuxe application is server-side rendered out of the box. When a request arrives, the server runs your Vue component tree, streams the resulting HTML to the browser, and the Vue runtime then hydrates that HTML on the client to make it fully interactive. You do not need to configure anything to enable SSR — it is the default mode for every page.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlkit/nuxe/llms.txt
Use this file to discover all available pages before exploring further.
How SSR works in Nuxe
Nuxe uses Nitro as its server engine. Incoming HTTP requests are handled byhandler.ts, which orchestrates the following steps:
Request arrives at Nitro
Nitro receives the HTTP request and forwards it to the Nuxe handler as a Web-standard
Request object.Vue app is created
The handler loads the SSR entry (
entry-server.ts) and creates a fresh Vue app instance for each request, providing the current URL and an SSR context object.HTML is streamed
Nuxe calls
renderToWebStream from vue/server-renderer to render the app tree into a ReadableStream. Chunks of HTML are emitted as Vue resolves async components and onServerPrefetch hooks. The <head> shell (populated by useHead) is emitted first, followed by the streamed component output.Payload is serialised
After the component tree is fully rendered, Nuxe serialises the SSR payload —
useAsyncData results, useState values, and public runtime config — into a window.__NUXE__ script tag appended to the HTML before the closing </body>.Dev vs production
Nuxe has two runtime modes with different serving strategies:vite-node to execute the server-side entry on every request. This means you get hot-module replacement without restarting the server — changes to pages, layouts, and composables are reflected immediately.
In production, nuxe build runs two Vite builds (a client environment and an ssr environment) and outputs them to .output/. The client assets (JS, CSS) are written to .output/public/; the SSR bundle is at .output/server/ssr/index.js; and the Nitro server entry point is at .output/server/index.mjs. nuxe start then serves both using the same Nitro-backed handler with no Vite overhead.
Per-page SSR control with routeRules
You can opt individual pages out of SSR without affecting the rest of your app by setting routeRules.ssr = false inside definePage. The server still delivers a minimal HTML shell so the client JavaScript can boot, but no server-side Vue rendering is performed for that route.
app/pages/spa.vue
_spa: true on the SSR context (set by the route-rules middleware), it short-circuits the render and returns a bare HTML shell:
Pages with
routeRules.ssr = false still receive this minimal HTML shell, so the client JavaScript boots and Vue mounts normally. The only difference from a full SSR page is that no server-rendered markup is inside <div id="app"> before hydration.Streaming
Nuxe usesrenderToWebStream from Vue’s server renderer to stream HTML as it becomes available. The response is sent with Transfer-Encoding: chunked, so the browser can start parsing and painting before the entire page is rendered on the server. Late-resolved <head> chunks (from async suspense boundaries) are injected inline as small <script> tags that are immediately removed after execution.
SSR-aware data fetching
useAsyncData and useFetch are fully SSR-aware. On the server they execute the fetch handler inside the request context and store the result in the SSR payload. On the client, hydration reads that payload instead of re-running the fetch — so your data is available immediately without an extra round-trip.
app/pages/fetch-demo.vue
useFetch wraps useAsyncData and additionally serialises the HTTP status code into the payload so client-side hydration reflects the exact response the server received.
Environment variables
| Variable | Default | Set by | Description |
|---|---|---|---|
PORT | 3000 | You | Port the dev and production servers listen on |
NODE_ENV | 'development' | You / framework | Controls build-time and runtime optimisations |
NUXE_BASE_URL | http://localhost:<PORT> | Framework | Full base URL used for internal SSR fetch requests; set automatically by nuxe dev and nuxe start |
NUXE_DEV | 'false' | Framework | Set to 'true' while nuxe dev is running; controls whether the handler uses vite-node or the pre-built SSR bundle |
PORT and NODE_ENV can be set in your shell or a .env file before running any nuxe command. NUXE_BASE_URL and NUXE_DEV are managed by the framework and should not normally be set manually.