Examples · Data & cache

Fetching data

resource() owns the async state; when() renders loading, error, empty and data.

No useEffect, no manual loading flags. A resource is a signal-shaped view of a request: data, loading, validating, error, refresh(). when() picks the branch.

Playground

What to notice

  • Reload keeps the old rows on screen while validating; only the first load shows the skeleton.
  • Every request appears in the Server requests panel with its latency.
  • rowsSignal in the data branch lets list() patch rows on refetch instead of rebuilding them.

Set window.__server.latency = 2000 at the top of app.js and reload.