How a widget gets its data, recorded in its widget.json so the build and tooling know what to expect. Today every widget is static; the prebake and live modes below are conventions reserved for widgets that need external data, and are not used by any widget yet.
A widget is a static bundle served from a Cloudflare Worker and embedded in an <iframe>. Its data is therefore either built into the bundle or fetched over the network when the widget runs. The data mode records which.
-
static(default) — all data is in the bundle; nothing is fetched at runtime. Thefunction-plotteris static: it computes its curve from the expression you type. Omitdata, or set{ "mode": "static" }. -
prebake(convention — not yet used by any widget) — the widget needs real external data, but it is fetched and written into the source tree beforenpm run build, so the deployed bundle stays self-contained. The widget commits a representativesamplefile (used during local development) and aprebakecommand that writes the realoutputfile; the widget loadsoutputwhen present and falls back tosample. -
live(convention — not yet used by any widget) — the widget fetches data at runtime (for example from its Worker). The committedsampleis the fallback used during local development, so the widget still renders without the network.
"data": {
"mode": "static | prebake | live",
"sample": "src/data/sample.json",
"output": "src/data/data.json",
"prebake": "npm run prebake"
}Required fields per mode (paths are relative to the widget directory):
static— omitdata, or just{ "mode": "static" }.prebake—mode,sample,output,prebake.live—mode,sample.
scripts/validate-widgets.mjs checks this shape whenever a widget includes a data block.
LIBRARIES.md— library menu and how to choose.README.md— project overview and default stack.