Web
What it does
apps/web is the reader site. It is one Foldkit21 program.
Foldkit is a UI framework on Effect: a Model, Messages, an update function, and a pure view.ΒΆ
Server rendering means the Worker builds the page HTML for each request. Prerendering means the build writes page HTML to files before deployment. Hydration means the browser program adopts HTML that the server rendered and continues from it.ΒΆ
One vite build makes three outputs:ΒΆ
- The browser bundle that hydrates each page.ΒΆ
- The server
fetchfunction that Foldkit generates fromsrc/entry.server.ts.ΒΆ - One HTML file for each path in the server entryβs
prerenderPathsexport.ΒΆ
Cloudflare.Website.Foldkit deploys the outputs as one Worker. A request for a prerendered page gets the file. Any other request goes to the server fetch function. It renders the page, an error page, or a 404 with its real status.ΒΆ
The server forwards /rpc to the private RpcBackend Worker. Browser Commands call capabilities through that path.ΒΆ
The standard
vite.config.tsturns on rendering with onefoldkit({ ssr })call. It uses the defaultdist/clientanddist/serverdirectories.ΒΆ- The server entry exports
renderPage,renderDocument, andprerenderPaths.ΒΆ - Every finite public page is prerendered. Pages that depend on the request render on the server.ΒΆ
- Readable content and links work before browser JavaScript runs.ΒΆ
- A missing page returns a real 404. It never falls back to the home page.ΒΆ
- Production builds contain no development modules, devtools code, or test people.ΒΆ
How to check
- Run
pnpm --filter @rat-stack/web build. Readapps/web/dist/server/foldkit.build.json. It namesfetch.jsas the server entry and lists the prerendered paths.ΒΆ - Run
pnpm --filter @rat-stack/web testfor page parity and the production-bundle exclusion test.ΒΆ - Run
pnpm --filter @rat-stack/infra test. The Website build test builds through Alchemy, reads prerendered pages, and serves them,/rpc, and a 404 from the server bundle in workerd.ΒΆ - On a preview, request a prerendered page and an unknown path with
curl. The page returns complete HTML withX-Preview-Commit. The unknown path returns 404.ΒΆ
Sources
- Web Vite configuration. GitHub joelhooks/rat-stack. The Foldkit plugin call that turns on the server build and prerendering. Accessed 2026-10-25.
- Website resource. GitHub joelhooks/rat-stack. The Alchemy resource that deploys the client assets and the server handler. Accessed 2026-10-25.
- Server entry. GitHub joelhooks/rat-stack. The render function, the document renderer, and the prerendered paths. Accessed 2026-10-25.
- Website build test. GitHub joelhooks/rat-stack. Builds the Website through Alchemy and serves it from workerd. Accessed 2026-10-25.
Last changed 2026-10-25 in 1249a2c. Source on GitHub. Change log.
Linked from
- Agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
Web β The Foldkit reader renders on the server and prerenders its public pages; the browser hydrates the same view.
- Agent rules for rat-stack (AGENTS.md). What you may change, which commands to run, and which changes need approval.
Link context
Server rendering and prerendering are the default: one foldkit({ ssr: { serverEntry, clientEntry, build: { prerender } } }) call in vite.config.ts builds the client bundle, the server fetch handler, and an HTML file for every path in src/entry.server.tsβs prerenderPaths.
- Build and run rat-stack (README.md). What is in the repo, how the example works, and how to run it.
Server rendering and prerendering are on by default.
- CAFE names the Cloudflare, Alchemy, Foldkit and Effect stack. CAFE is a named stack: Cloudflare runs the app, Alchemy declares it, Foldkit draws the UI, and Effect does the typed work.
mwarger/corefour: A poster app with an Effect HttpApi Worker, Foldkit server rendering, and KV and R2 storage.ΒΆ
- Change log. What changed in the files served here, newest first.
Web β edited: feat: alchemy beta.84, effect 4.0.6, foldkit vite-plugin patch
- Effect 4 study: September 2026. Dated Effect 4 source studies from September 2026; current versions live in pins.md.
This upgrade changes no application machine to snapshot-based hydration.
- Full agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
- Rat Stack systems | rat-stack. The systems rat-stack ships, the standard each keeps, and how to check it.
Web β The Foldkit reader renders on the server and prerenders its public pages; the browser hydrates the same view.
- Source change history (log.md). The generated change log as Markdown.
Web β edited: feat: alchemy beta.84, effect 4.0.6, foldkit vite-plugin patch