Server-Side Overview
Three choices place an app on the server: the verdict the router gives a request, how much of the page the server renders, and the host that serves it. ui-router-server owns the verdict and the hosts; lit-ui-router-ssr owns the render. Pick one of each, then follow the row in Find your combination.
Verdict
What the router decides for a request from its url alone, before any of the app's code runs. The verdict lists the shapes; which decides when covers the answers a transition changes later.
| Answer | Declared as | Read |
|---|---|---|
| Page | a state with a url | Server-Side Routing |
| Redirect | a pattern rule in redirects, or a redirectTo | Redirects: data until they need code |
| 404 | no matching state, or the mount's otherwise | Real 404s, per mount, Unmatched URLs |
| Response state | response: true and a host handler | Response states |
| Delegate | delegate and a host handler | Delegating states |
Render
What the server sends for a page verdict.
- None. The server answers with the app's shell and the client renders the page. The verdict still sets the status, so a typo gets a real 404: Server-Side Routing.
- Static prerender. The build writes one HTML page per route, a 404 page and the host's redirect rules, and the client adopts the served page: Prerender with Vite, Prerender with Eleventy.
- Server render with hydration. A host renders each request's page with
renderToString, and the client wakes it under the hydration model.
Host
The runtime or framework that serves the request. Each host is an entry point of ui-router-server.
| Host | Entry point | Read |
|---|---|---|
| Fetch runtimes: Workers, Deno, Bun | ui-router-server/fetch | fetch |
| Hono | ui-router-server/hono | hono |
| Connect and Express | ui-router-server/connect | connect |
vite dev and vite preview | ui-router-server/vite | vite |
| A static host, from the build's output | ui-router-server/prerender | Emitting a static site |
Find your combination
| Render | Host | Start with | Working code |
|---|---|---|---|
| None | Workers | Server-Side Routing | This site's docs worker, serving the sample app mounts |
| None | vite dev, vite preview | vite | This site's vite.config.ts |
| None | Hono, Connect | Adapters | |
| Static prerender | Vite build | Prerender with Vite | hellosolarsystem-ssr; The Altitude Atlas, prerendered and hydrated |
| Static prerender | Eleventy | Prerender with Eleventy | hellosolarsystem-eleventy |
| Server render | Workers | Rendering one page per request | This site's release pages, rendered per request without hydration |
This site is the working code for the Workers rows; How this site runs describes its worker, the release ledger and the release pages.
The API references for both packages are at /reference/ui-router-server/ and /reference/lit-ui-router-ssr/.