Bento Spaces documentation
Widgets
A widget fills a container. It never owns geometry. Two formats exist; the first is safe by construction and is the default.
The manifest
Every widget, in every format, ships a manifest. It is the only thing the editor needs to decide whether a widget fits a container.
{
"id": "clock",
"name": "Clock",
"version": "1.2.0",
"sizes": ["1x1", "2x1", "2x2", "4x2"],
"defaultSize": "2x1",
"fit": "exact",
"role": "ambient",
"refresh": null,
"vars": [],
"data": null,
"permissions": { "network": [], "actions": [] }
}
| Field | Meaning |
|---|---|
sizes | the renderings the developer actually drew, in boxes |
defaultSize | what the picker inserts by default |
fit | exact (only listed sizes), nearest (closest size, letterboxed), stretch (any size) |
role | ambient (glanceable) or interactive (needs big hit areas) |
refresh | null, "5s", "30s", "60s", "5m", "10m"; a data widget with no field defaults to "5m", explicit null disables polling |
vars | names a widget may interpolate into its data URL |
data.mode | proxy: the host fetches; client is accepted as a legacy alias but still goes through the host |
data.url | absolute http(s) URL or a /path on this Bento Spaces host |
data.path | optional dot path into the JSON, used by {{data}} |
data.cacheTtl | 0s, 5s, 30s, 60s, 5m, 10m |
permissions.network | origins the widget may read, or "self" for this host |
permissions.actions | open, refresh, setProps (modules only) |
permissions.connector | true lets the declared action post through an account connector |
Fit rules in the editor. A widget can only be dropped into a container whose size is in sizes, or any size when fit is stretch. Illegal targets dim to 50% with a red border and refuse the drop. Containers are locked while filled, so a resize can never create a mismatch.
Built-ins
Twenty-one trusted modules live in web/src/widgets/builtin/. All but gree, http and ha are secret-free: they stay visible in shared views and in an HTML export. See 14 — Widget catalogue for the tier model.
| Widget | Sizes | Notes |
|---|---|---|
| clock | 1×1, 2×1, 1×2, 2×2, 4×2 | ticks every second; optional second timezone |
| stat | 1×1, 2×1, 2×2, 4×2 | label + value + unit |
| note | anything (stretch) | double-click to edit |
| links | 2×1, 2×2, 4×2, 4×4 | opens in a new tab |
| image ("Photo frame") | anything (stretch) | one or more URLs, cross-fade slideshow |
| progress | 2×1, 4×1, 2×2, 4×2 | 0..1 bar |
| countdown | 1×1, 2×1, 2×2 | ticks every second only while it has a target; optional yearly repeat |
| weather | 1×1, 2×1, 2×2, 4×2 | Open-Meteo; current, feels-like, 3-day forecast |
| feed | 2×1, 2×2, 4×1, 4×2, 2×4, 4×4 | RSS/Atom through /api/live/feed |
| markets | 2×1, 4×1, 2×2, 4×2, 2×4, 4×4 | CoinGecko coins + Frankfurter FX |
| qr | 1×1, 2×1, 2×2, 4×2 | local encoder (v1–10, L/M/Q/H), drawn as SVG |
| sun | 1×1, 2×1, 2×2, 4×2 | sunrise/sunset + moon phase; Open-Meteo daily |
| units | 1×1, 2×1, 2×2, 4×1, 4×2 | local unit conversion, no network |
| dice | 1×1, 2×1, 2×2, 4×2 | d2–d100, up to 12 dice, or a list picker |
| holidays | 1×1, 2×1, 2×2, 4×1, 4×2, 2×4, 4×4 | Nager.Date, next public holidays |
| crypto | 2×1, 2×2, 4×1, 4×2 | CoinGecko market chart + sparkline |
| air | 1×1, 2×1, 2×2, 4×2 | European AQI, PM2.5, PM10 |
| gree | 2×1, 2×2, 4×2 | account connector to a local Gree bridge; power, temperatures, toggle |
| http ("HTTP card") | 1×1, 2×1, 2×2, 4×2 | one connector path mapped to dotted-path fields; templates and inferred fields |
| ha ("Home Assistant") | 1×1, 2×1, 2×2, 4×2 | one HA entity: state, unit, friendly name, toggle for lights/switches/fans |
| transit ("Departures") | 2×1, 2×2, 4×1, 4×2 | TfL or BVG departures for a stop, 60 s refresh |
Where their data comes from. Either a direct fetch to a CSP-allowed public host, or the API-hosted /api/live/feed proxy for feeds (which do not send CORS headers). Widgets never hold a token, and a failed request paints a one-line message in the box.
Configuration. A widget that has settings declares config: { title, fields } — field types are text, number, boolean, select and textarea; a select lists strings or { value, label } pairs. In edit mode the shelf shows a gear on hover and opens one shared settings dialog for every widget. A widget with a custom action instead of fields exports configure(el, ctx) (Gree uses this to open the connector list). View-mode double-click is reserved for shortcuts and never opens a prompt.
Refresh is per placement. Every polling widget also has a Refresh… entry in the block menu: Default (which names the widget's own interval, e.g. Default (10 minutes) for weather), Off, 30 s, 1 min, 5 min, 10 min, 30 min or 1 hour. The choice is stored in that placement's props with its space, so one weather card can poll every minute and another every hour; Off loads once and stops. Widgets that do not poll (clock, countdown, note, …) do not offer it. The timer helper is shared, so a new polling widget gets the same behaviour by using startRefresh/stopRefresh from web/src/widgets/refresh.js.
Auditing the catalog. node scripts/audit-widgets.mjs compares the 21 built-ins with the marketplace releases: ids, names, manifest validity, hashes, sizes and functional overlap. node scripts/e2e/widget-sweep.e2e.mjs mounts every built-in at every declared size in a real browser and destroys it again. tests/widgets.test.js also fails if a .wg-* rule gives a font-size in px: widget text has to stay in em so the device zoom scales it.
Installed widgets and the in-app marketplace
The add-widget picker lists the account's library: the built-ins it has enabled plus the registry widgets it has installed. With a large catalog that stays small; adding a widget type to the library is an explicit act.
- Search in the picker filters by name and id.
- Marketplace in the picker footer and next to the settings gear opens a popup with three
- tabs:
- Explore — AltStore-shaped browse. It opens on Suggested with two chip rows:
- sources (All sources · WidgetMarket · custom registries) and categories
- (**All · Suggested · Time · News · Money · Weather · IoT · Photos · Productivity · Developer ·
- Fun · Travel**). Cards are tonal, carry a two-letter monogram or the uploaded icon, source/version
- and one Install/Update/Remove action. Clicking a card opens its store page: tinted hero,
- description, category tags, sizes, a clickable publisher profile, the last versions with
- release notes, network permissions, and a feedback form that keeps your own thread and the
- developer's replies. A Report button sends the release to the operator (broken, misleading,
- unsafe, spam or other); the publisher never sees who reported. Installing a widget subscribes
- you to a notification when the publisher ships a newer market release. Bento Spaces' own widgets are entries in the WidgetMarket source,
- not a source of their own. Suggested is the marketplace's
- curation: the operator picks ids in
/manage, the index exposes them, and a widget never - carries that tag itself.
- Installed — the whole library, built-ins included, with Remove. An outdated install shows
- Update; an update asks only for permissions it adds, and Update all applies every
- permission-neutral update in one go, leaving the rest for review. Removing here
- uninstalls the type, not a placement: every space keeps its box and its values, and the
- shelf shows "Widget removed — reinstall to restore" until the same widget id is installed
- again. The same Remove button sits on installed cards in Explore.
- Sources — the registries, as tinted cards with their widget count, type and a Browse
- action. There are two kinds: a Marketplace aggregates many developers (WidgetMarket is
- the built-in one and cannot be removed), while a Developer registry is one person's
- own feed for testing or self-publishing. The add form asks for the type. An unreachable
- source is tagged offline instead of failing the whole catalog.
- The popup is 800px × 90vh on a desktop and 90vw on a small screen.
- Explore lists installable entries. WidgetMarket contains Bento Spaces' 21 built-ins and the
- marketplace releases; a custom registry adds its own entries. Installing a built-in re-enables
- it locally — there is nothing to download.
- An installed entry swaps Install for Remove, unless a newer release exists — then it says
- Update and installing moves the library to the latest version. The Installed tab shows
- Update beside Remove when one is available. If the type is placed anywhere, Remove first asks
- for confirmation and names the spaces and box counts; cancelling keeps the library as it was,
- confirming hides the widget but leaves every box for a later reinstall.
- A user may remove every widget, built-ins included. The picker then says so and the
- Marketplace is one tap away. New accounts start with the operator's defaults
- (
/manage); existing accounts keep their library. - Installs are hash-pinned and carry the marketplace's permission declaration, exactly like a
- hand-added registry.
- The marketplace source is built in when the API sets
Marketplace:Url(see - 17 — Split deployment); otherwise the popup asks for a registry URL once and
- remembers it on this device.
- Single-host dev serves the marketplace at
/marketplace, so the popup works out of the box; - five-address dev does the same on the webtop host.
Declarative widgets (shipped in P4)
Beyond the built-ins, a widget can be a JSON manifest with no code. It is validated by one shared module (web/src/widgets/declarative.js), installed from a registry, and interpreted by the same renderer. Render types: stat, badge, text, list, image, progress, clock, link.
{
"id": "deploy-status",
"name": "Deploy status",
"version": "1.0.0",
"sizes": ["1x1", "2x1", "2x2"],
"defaultSize": "2x1",
"fit": "exact",
"role": "ambient",
"refresh": null,
"vars": [],
"data": null,
"render": { "type": "stat", "label": "Deploy", "value": "ok", "unit": "" }
}
Data through the host proxy
A declarative widget reads JSON by declaring where it comes from. The browser calls POST /api/widgets/{id}/{version}/data; the host checks the installed manifest and fetches. The widget never talks to the network itself.
{
"id": "site-status",
"name": "Site status",
"version": "1.0.0",
"sizes": ["1x1", "2x1", "2x2"],
"defaultSize": "2x1",
"fit": "exact",
"refresh": "30s",
"data": {
"mode": "proxy",
"url": "/example-data/status.json",
"path": "deploy",
"cacheTtl": "30s"
},
"permissions": { "network": ["self"], "actions": [] },
"render": { "type": "stat", "label": "Deploy", "value": "{{data}}" }
}
permissions.networkmust cover the URL's origin (https origins, or"self"); a relative URL needs"self".{{data}}resolves todata.path;{{data:some.path}}reads any path;{{var:name}}- interpolates a prop. Values are URL-escaped when used in the URL and HTML-escaped when
- rendered.
refreshre-fetches;cacheTtllets the host answer repeats without going upstream.- The install dialog shows the requested network origins and actions before anything is
- installed. The registry index is the consent: a manifest may narrow it, never widen it.
If the fetch fails the widget says Unavailable instead of showing stale or fake data.
Connector data
Instead of data.url, a widget can read through an account connector:
{
"permissions": { "network": [], "connector": true },
"data": { "mode": "connector", "connector": "/api/state", "path": "armed" },
"render": { "type": "stat", "label": "Blocking", "value": "{{data}}" }
}
data.mode: "connector"sends aGETthroughPOST /api/connectors/{id}/request.data.connectoris an absolute path on the connector — no scheme,//,..or whitespace — and- may interpolate
{{var:…}}. data.pathkeeps its meaning: the dot path into the returned JSON.- It needs
permissions.connectorexactly like an action, and the same auto-bind (or picker) - applies, so a card can both read and act on one connector.
data.connectorKindnarrows the binding to one kind —"spotify"for an OAuth connector, or"homeassistant","gree"and"http"for manual ones.data.urlanddata.connectorare mutually exclusive;refreshandcacheTtlbehave as usual.- Shared views show “Private connector”; the export still records the last snapshot.
Actions (connectors)
A declarative widget can act on one account connector — a button, not a script. It has to ask for the permission and declare exactly one action:
{
"permissions": { "network": [], "connector": true },
"render": { "type": "stat", "label": "Blocking", "value": "Armed" },
"action": {
"label": "Disable blocking",
"method": "POST",
"path": "/api/blocking?disable=600",
"body": { "note": "{{var:reason}}" }
}
}
- The command goes through the existing connector proxy, so the account's token, the
- origin/path rules, GET-and-POST-only and the 8 s timeout apply unchanged.
pathmust be an absolute path on the connector: no scheme, no//, no.., no whitespace.methodisGETorPOST(defaultPOST).bodyis an object under 4 KB, and its strings- may interpolate
{{var:…}}and{{data:…}}. - The widget binds the account's only connector automatically, narrows by
connectorKindwhen - given, and otherwise shows a picker.
- Installing is refused unless the manifest asks for
permissions.connector, and the detail - panel shows a connector tag beside the origins, so the consent list always names it.
- Shared views, signed-out sessions and HTML exports carry no action: a view session has no
- connectors, and an export records an interactive placeholder.
A bundled example registry lives at /registry-example.json (three widgets under /example-widgets/), so the whole flow can be tried without hosting anything.
Format B — sandboxed modules (shipped in P5)
A manifest can carry source instead of a render spec:
{
"id": "pulse",
"name": "Pulse",
"version": "1.0.0",
"sizes": ["2x2", "4x2"],
"defaultSize": "2x2",
"fit": "exact",
"render": { "type": "module" },
"module": {
"source": "self.widget = { mount(el, ctx) { … } }",
"assets": [
{ "name": "helper.js", "text": "self.helper = 1;" },
{ "name": "theme.css", "text": ".card { color: var(--accent); }" }
]
}
}
The source is a classic script that defines self.widget with mount(el, ctx), update(el, ctx) and destroy(el). ctx exposes props, size, setProps(patch), emit(name, payload), request({ url }), asset(name), open(url) and refresh().
Assets. Up to five text files (1–32 KB each, 96 KB total) travel inside the immutable release. ctx.asset("helper.js") returns the text or null; the module decides how to use it (a <script>, a <style>, JSON). Nothing is fetched: the frame receives the map as window.__bentoAssets before the module runs, and assets may not contain </script.
Studio can author this format: the module source gets its own editor, Add asset files bundles text assets into the manifest, and the sandboxed preview uses the same CSP; everything ships inside the manifest. It runs in an iframe with sandbox="allow-scripts" and no allow-same-origin, so the origin is opaque: no cookies, no storage, no parent DOM. The frame document is served by the host at /api/widgets/{id}/{version}/frame with its own CSP (sandbox allow-scripts; default-src 'none'; …; connect-src 'none'), so the frame itself still cannot touch the network. Because an opaque-origin frame sends no cookies, the client first requests a 12-hour frame token and puts it in the URL.
ctx.request({ url }) posts to the parent, which calls the same proxy as declarative widgets. The URL must be inside permissions.network. ctx.open(url) opens a link (requires actions: ["open"] and a network origin), ctx.refresh() asks the shelf to call update, and ctx.setProps(patch) requires actions: ["setProps"]. Actions and origins are shown at install and enforced in the parent and on the server.
Source is capped at 64 KB and may not contain </script; asset rules are in the same validator. The frame's base font-size follows the bento zoom, so author module CSS in em/rem to scale with the board.
The harness at /harness.html renders modules too (with the same token flow).
Format A — declarative (reference)
No code runs. The host renders a small vocabulary from JSON, which means a widget can be reviewed by reading ten lines, and an AI can generate one safely.
{
"id": "gpu-temp",
"name": "GPU temperature",
"version": "1.0.0",
"sizes": ["1x1", "2x1", "2x2"],
"defaultSize": "2x1",
"fit": "stretch",
"refresh": "30s",
"data": {
"mode": "proxy",
"url": "https://api.example.com/gpu",
"path": "temp",
"cacheTtl": "30s"
},
"permissions": { "network": ["https://api.example.com"], "actions": [] },
"render": { "type": "stat", "label": "GPU", "unit": "°C", "value": "{{data}}" }
}
Data: host-proxied GET, refresh, optional cacheTtl, a simple dot path, and {{data}} / {{data:path}} / {{var:name}} interpolation. Render: stat, text, list, image, progress, badge, clock, link. Actions: declarative widgets have none yet; actions belong to sandboxed modules.
Rules: no script, no eval, no remote CSS or fonts, https images only, text always escaped, prefers-reduced-motion respected, 44 px touch targets.
Where widgets live
data/users/{userId}/widgets/library.json ← built-ins this account removed
data/users/{userId}/widgets/{widgetId}/{version}/ ← installed bundles, all that user's spaces
data/users/{userId}/widgets/settings/{widgetId}.json ← shared defaults (connector id only, today)
data/users/{userId}/spaces/widgets/{instanceId}.json ← one placement's values, no space
web/src/widgets/builtin/ ← built-in modules, shipped with the client
The library is available in every space that user owns, never to anyone else. Containers reference { "type": "clock", "version": "1.2.0" }; the loader renders a built-in only while its id is enabled in the library, otherwise it uses the installed manifest. A disabled built-in is not deleted — its code is part of the client — so re-enabling it restores every placement.
Instance values sit outside any space, next to layout.json rather than inside it. That is what makes the block menu's Move to space… a two-layout edit: the widget and all its props change owner, and widgets/settings/{widgetId}.json is not touched. Copy to space… creates a new instance with cloned props; the two copies then evolve independently.
Common settings resolve as instance props > widgets/settings/{widgetId}.json > manifest defaults. Only gree ships a common file today (the connector id); deviceId stays per instance so two rooms never collide.
Uninstalling a type never deletes instance values, so reinstalling the same id restores every placement in every space. Remove from space is the placement action: it trashes the instance and removes the container, and the shelf undo puts both back. Trash is pruned after seven days.
Registries (federated)
A registry is a static registry.json that anyone can host — a company, a gallery on GitHub Pages, the Official source.
{
"schema": 1,
"name": "Bento Official",
"suggested": ["clock", "weather"],
"widgets": [{
"id": "clock",
"name": "Clock",
"developer": "Bento",
"tags": ["time"],
"latest": "1.2.0",
"versions": [
{ "version": "1.2.0", "notes": "Faster startup", "url": "https://…/clock/1.2.0.zip",
"sha256": "…", "sizes": ["1x1","2x1"], "permissions": { "network": [], "actions": [] } }
]
}]
}
tagsbelongs to the widget and drives the category chips. Unknown tags get a chip too, so a- registry can introduce a category without a client change.
suggestedbelongs to the marketplace index, not the widget: it is the curatedSuggestedcategory. A source without it simply has no Suggested view.developeris optional; cards use it as the byline, falling back to the source name.- Sources are per user: the Official registry plus anything they add. Signed-out local boards
- keep their built-ins but cannot install; the dialog asks for a sign-in.
- Hashes only. Every version is sha256-pinned on install and verified on load. No
- signatures, no publisher vetting, no gatekeeping — pointing at your own gallery is allowed.
- Built-in ids (
clock,image, …) are reserved: a registry may use its own id such as world-clock, but cannot replace the client module of the same name.- Versions are immutable:
id/version/is cached for a year,registry.jsonisno-store. - Install flow: fetch index (server-side, avoids CORS) → verify hash → store in the user's
widgets/→ pin the version on the container.- Upgrading is explicit ("Clock 1.2.0 is available — update 3 containers?").
Developer tooling
published/wwwroot/widgets/_harness/renders any widget at every declared size, in every- space, with fake props.
scripts/check-widgets.mjsvalidates manifests: id shape, semver, sizes within 1–4 boxes,- allowed refresh values, declared vars exist, referenced files present, no absolute or
javascript:URLs.- A valid widget zip is:
manifest.json, optionalwidget.js, optionalwidget.css, - optional
icon.svg, nothing else.
Caching and offline
| Asset | Cache |
|---|---|
widget files (id/version/…) | max-age=31536000, immutable |
registry.json | no-store |
widget data (/api/widgets/*/data) | no-store unless the manifest sets cacheTtl |
| installed bundles | service worker runtime cache |
| the app shell | network-first with a cache fallback; see 15 — PWA and offline |
| last widget reading | localStorage snapshot, rendered stale when a refresh fails |
While idle (see UI) widgets are unmounted and refresh stops; waking remounts and refetches.