The sandbox globals
Your script is executed with these variables already in scope — you don’t import anything:| Global | Purpose |
|---|---|
widget | Read and control widgets (reference) |
ws | Send and receive realtime messages (reference) |
storage | Persist small values on the client (reference) |
db | Query and insert database records (reference) |
location | Read device geolocation (reference) |
context | Product, device, and user info (reference) |
sensor | Product sensor helpers |
usb | Product USB helpers |
pdf | PDF export helpers |
console | Logging — output appears in the script console |
fetch | Standard fetch for HTTP requests |
setTimeout / setInterval | Standard timers |
A first script
When to use scripts
- Glue logic between widgets — when one changes, update another
- Custom realtime handling — interpret incoming device messages your own way
- Client-side persistence — remember a user’s last choice
- Data-driven UI — query the database and render the result
widget
Values, text, visibility, layout, config, events.
ws
Realtime send / receive.
db
Query and insert records.
Events
The full widget event vocabulary.

