Reference: Dashboard SDK
The Dashboard SDK consists of two npm packages, both provided to widget packs by the dashboard at runtime:
| Package | Contains | Version |
|---|---|---|
@modbros/dashboard-sdk | Hooks, components, utilities and errors for widgets | 1.4.2 |
@modbros/dashboard-core | Types shared with MoBro, like ChannelValue, and metric formatting utilities | 1.3.0 |
This reference describes the versions listed above.
Imports
Import hooks, components and utilities from @modbros/dashboard-sdk, and types from @modbros/dashboard-core:
src/widgets/example/Example.tsx
import React from 'react'
import {useMetricField} from '@modbros/dashboard-sdk'
import type {ChannelValue} from '@modbros/dashboard-core'
export default function Example() {
const channelValue: ChannelValue | null = useMetricField({field: 'metric'})
return <span>{channelValue?.value.value}</span>
}
Contents
- Field hooks read and update the values of the fields users configure.
- Hooks access the widget's position and size, MoBro's settings, and format metric values.
- Components render repeater items, loading indicators and placeholders.
- Utilities manage complex state within a widget.
- Errors thrown by the SDK.
- Types of field values and metrics.