MDK Logo

Utility

General utility and helper hooks

General-purpose utility hooks.

Package

@tetherto/mdk-react-adapter

Hooks

@tetherto/mdk-react-adapter

Import the public APIs on this page 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

On this page