Documentation
Docs
Introduction
Getting Started
Tutorial: build an app
Core Concepts
Routing
Server-Side Rendering
Mimir, state management
Pages & Layouts
API Routes
Styling & Theming
Building & Deploying
API Reference
Guides
Recipes
FAQ (use cases)
Pages
A page is the unit of routing: a module under pages/ whose default export is the component for a URL.
It may also export ssr() for server-side metadata and seed state. This page is the reference for the page
module contract.
The contract
default, the React component rendered for the route. Required, without it the route renders nothing.ssr(), optional, server-only. Returns{ title?, head?, __atoms? }. Its presence makes a static
route a fully server-rendered, cached page. See The ssr() function.
That is the whole contract. A page is "just a component" with one optional server hook.
Registering a page
scanRoutes discovers the file and gives you its pattern and pageKey; you map the pattern to the
imported module and call app.page:
app.page(path, component, meta) accepts either the module namespace (with default + ssr) or the
component directly. The meta.page is the manifest key that tells the server which client chunk to ship.
Props a page receives
For static SSR pages, the component is called with no props (data comes from atoms/imports). For shell
routes (dynamic, or static without ssr()), the hydration payload carries props with params, query,
and path, and the page reads the location through the router hooks:
Use the router hooks rather than expecting props, they work on both server and client and keep your component environment-agnostic.
Server vs client execution
A page component runs in two places: on the server during SSR (to produce HTML) and in the browser after hydration (to become interactive). Write it so it produces the same output in both:
- Do not read
window/document/localStorageduring render, seed viassr().__atomsor read in an
effect (see SSR → hydration).
ssr()runs only on the server, it is the right place for server-only metadata, never for client UI.
Pages vs components
Everything under pages/ (except convention files) is a route. Everything under components/ is a plain
component you import, not a route. A page typically composes components:
Convention files are not pages
layout.tsx, error.tsx, not-found.tsx, loading.tsx, route.tsx (and _-prefixed variants) have
special roles and are not registered as routes. See Conventions.
Next: the chrome around pages, Layouts.