API reference

Velz keeps the surface small on purpose. This page is the whole of it. Run velz info for the same content as JSON.

Reactivity

The primitives are React's, so the code reads the way every React project reads. Nothing to learn, and every React component on npm works as it is.

ExportWhat it does
useStateState that survives a render. It returns the value and a setter.
useMemoA value that is only recomputed when its sources change.
useEffectRuns after the render, and again when something it read changes. The cleanup runs when the component goes.
useRefA value that survives a render without causing one. A DOM node lives here.
useContextReads a context. The route is one of them.

Routing

ExportWhat it does
useRouteThe current path, params, query and hash.
useParamsJust the dynamic segments of the current route.
navigateMoves to another path. Client side when the router is mounted.
LinkAn anchor that navigates without a full page load.

Page props

Every page receives the same props.

PropType
paramsRecord of dynamic segments
queryURLSearchParams
dataWhatever the load function returned
requestThe incoming Request
urlThe parsed URL

Head

The Head component collects title, description, canonical and social tags while the page renders.

head.tsx
<Head
  title="Product"
  description="What it does, for whom."
  image="/og.png"
/>

Islands

Any component in src/islands is rendered on the server and hydrated in the browser. Props cross the boundary as JSON, so keep them serialisable.