Web layer
This page maps the web-layer guides. The web layer is @netscript/fresh, a server-first
meta-framework built on Fresh 2.x and Preact. Its pages load data through
the same contract object your services implement, so when a contract changes, the page that
depends on it fails deno check instead of failing in production.
In a scaffolded workspace, apps/dashboard/lib/example-service.ts imports UsersContractV1 and
derives a typed client and TanStack Query factories from it. The users service implements the same
contract. Reshape an endpoint and every page loader, island and form that consumes it becomes a
compile error with a file and line number.
How a page is put together
You author a page with definePage(). It binds a typed route contract, server resources,
layers (each with its own loader, cache window and partial-refresh endpoint) and forms, then
builds them into Fresh route wiring. Handlers run in Deno and return HTML. Only components under
islands/ ship JavaScript to the browser, where they hydrate against the same query cache the server
dehydrated.
Guides
Each guide covers one part of that model. Read the one you need.
- Fresh page model: server-first rendering, the islands boundary, and
defineFreshApp()from@netscript/fresh/server, the bootstrap every NetScript Fresh app starts from. - The define-page builder:
definePage()anddefinePartial()from@netscript/fresh/builders, with typed layers, defer policies and per-layer partial refresh. - Request-scoped resources:
withResource(), one value resolved once per request and shared by every layer, layout and metadata resolver on the page. - Layers, layout, and slots:
withLayer()andwithLayout(), named regions that resolve concurrently, each with its own loader, fallback and freshness window. - Response shaping:
withMeta(),withHeader(),withStatus(), and theGEThandlerbuild()synthesises from them. - Route contracts:
defineRouteContract(), schema helpers such aspaginationSearchSchema()anddefineEnumPathParam(), and the generatedroutestree that turns a moved route file into a compile error. - Generated web surface: which files in a Fresh app you own and which the route generator rewrites.
- Partials:
definePartial(), paired route references, and the layer config that turns a region into a cache-aware deferred partial. - Deferred & streaming UI: stream a fallback now and swap in real content when a slower layer resolves.
- Data loading & the query cache:
QueryIsland,useQuery,useMutationanduseLiveQuery, the TanStack Query bridge that shares one cache between server render and island hydration. - Query bridge: SDK query factories from loader to island, the two
key tiers,
getCachedEntry()as a read rather than a fetch, and when to dehydrate instead of passinginitialData. - Server-validated forms: typed, contract-aware form handling declared as a page layer.
- Interactivity and durable-stream consumption: island runtime helpers and the browser-side client for durable HTTP/SSE streams.
- Vite integration, testing and diagnostics. For a worked example of the whole layer, follow the Live Dashboard tutorial.
- Fresh UI & design: the visual layer on top, with the copy-source component registry, design tokens and the scaffolded dashboard app.