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.
| Export | What it does |
|---|---|
| useState | State that survives a render. It returns the value and a setter. |
| useMemo | A value that is only recomputed when its sources change. |
| useEffect | Runs after the render, and again when something it read changes. The cleanup runs when the component goes. |
| useRef | A value that survives a render without causing one. A DOM node lives here. |
| useContext | Reads a context. The route is one of them. |
Routing
| Export | What it does |
|---|---|
| useRoute | The current path, params, query and hash. |
| useParams | Just the dynamic segments of the current route. |
| navigate | Moves to another path. Client side when the router is mounted. |
| Link | An anchor that navigates without a full page load. |
Page props
Every page receives the same props.
| Prop | Type |
|---|---|
| params | Record of dynamic segments |
| query | URLSearchParams |
| data | Whatever the load function returned |
| request | The incoming Request |
| url | The parsed URL |
Head
The Head component collects title, description, canonical and social tags while the page renders.
<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.