Skip to content

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.

AnswerDeclared asRead
Pagea state with a urlServer-Side Routing
Redirecta pattern rule in redirects, or a redirectToRedirects: data until they need code
404no matching state, or the mount's otherwiseReal 404s, per mount, Unmatched URLs
Response stateresponse: true and a host handlerResponse states
Delegatedelegate and a host handlerDelegating 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.

HostEntry pointRead
Fetch runtimes: Workers, Deno, Bunui-router-server/fetchfetch
Honoui-router-server/honohono
Connect and Expressui-router-server/connectconnect
vite dev and vite previewui-router-server/vitevite
A static host, from the build's outputui-router-server/prerenderEmitting a static site

Find your combination ​

RenderHostStart withWorking code
NoneWorkersServer-Side RoutingThis site's docs worker, serving the sample app mounts
Nonevite dev, vite previewviteThis site's vite.config.ts
NoneHono, ConnectAdapters
Static prerenderVite buildPrerender with Vitehellosolarsystem-ssr; The Altitude Atlas, prerendered and hydrated
Static prerenderEleventyPrerender with Eleventyhellosolarsystem-eleventy
Server renderWorkersRendering one page per requestThis 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/.