MDK Logo
ReferenceUIHooks

Utility Hooks

General utility and helper hooks

General-purpose utility hooks.

From @tetherto/mdk-react-adapter

useBeepSound

Plays a repeating beep sound at a configurable interval.

({ isAllowed = DEFAULTS.IS_ALLOWED, volume = DEFAULTS.VOLUME, delayMs = DEFAULTS.DELAY_MS, }: UseBeepSoundOptions = {}) => void

useContextualModal

Headless open/close state for a modal that needs to remember the subject it was opened against (the row being edited, the device being inspected, etc.).

({ onOpen, onClose, }: UseContextualModalParams = {}) => { modalOpen: boolean; handleClose: () => void; handleOpen: (sub: T | null) => void; subject: T | null; setSubject: React.Dispatch<React.SetSta…

useDeviceResolution

Hook to detect current device resolution/viewport size

() => DeviceResolution

useKeyDown

Tracks whether a specific keyboard key is currently held down.

(keyName: string) => boolean

useLocalStorage

Custom hook for type-safe localStorage access with cross-tab sync.

(key: string, defaultValue: T) => [T, (value: T | ((prev: T) => T)) => void, VoidFunction]

usePagination

Custom hook for managing pagination state

(args: PaginationArgs = {}) => UsePaginationReturn

usePlatform

SSR-safe React hook returning the detected client OS.

() => PlatformResult

useSubtractedTime

Returns Date.now() - diff, refreshing on a fixed interval (default 5s).

(diff: number, interval = DEFAULT_INTERVAL) => number

useTimezoneFormatter

Timezone-aware date formatting hook.

() => UseTimezoneFormatterReturn

useWindowSize

Hook to track window size changes

() => WindowSize

From @tetherto/mdk-react-devkit

useCostSummary

Base hook for the cost-summary reporting page (single-site mode).

({ query, ...dateRangeOptions }?: UseCostSummaryOptions) => { queryParams: CostSummaryQueryParams | null; isLoading: boolean; error: {} | null; metrics: CostSummaryDisplayMetrics | null; costLog: readonly CostTimeSeriesEntry[]; btcPriceLog:… /* see source */

On this page