Skip to main content
The context global describes who and what the script is running for.

Shape

context.productId   // string | null
context.deviceId    // string | null
context.user        // { id, email, role } | null
context.device      // environment info (see below)

Environment info — context.device

Describes the viewing device (the browser/screen the dashboard is shown on):
context.device.type          // 'mobile' | 'tablet' | 'desktop'
context.device.isMobile      // boolean
context.device.isTablet      // boolean
context.device.isDesktop     // boolean
context.device.screenWidth   // number
context.device.screenHeight  // number
context.device.orientation   // 'portrait' | 'landscape'
context.device.touchEnabled  // boolean

Example — responsive behavior

if (context.device.isMobile) {
  widget.hide('sidebarChart');
}

if (context.user?.role === 'admin') {
  widget.show('adminControls');
}

Next: Events

The full widget event vocabulary.