MDK Logo
ReferenceUIHooks

Dashboard Hooks

Dashboard data fetching and state management hooks

Hooks for dashboard data and state management.

From @tetherto/mdk-react-adapter

useActiveIncidents

TanStack Query hook returning the list of currently-firing alerts, shaped for <ActiveIncidentsCard items={...} />.

(options: UseActiveIncidentsOptions = {}) => UseQueryResult<IncidentRow[], Error>

useCancelAction

Cancels pending actions via DELETE /auth/actions/:type/cancel?ids=…. Invalidates the pool/miner/actions caches on success. Gated by actions:w.

() => UseCancelActionResult

useConsumptionChartData

TanStack Query hook returning raw consumption tail-log samples. Most dashboards should consume the higher-level useSiteConsumptionChartData, which wraps this hook with the site powermeter defaults and returns a &lt;LineChartCard&gt;-ready `C…

(params: UseConsumptionChartDataParams) => UseQueryResult<TailLogEntry[], Error>

useContainerPoolStats

Fetches per-container pool override counts from GET /auth/pools/stats/containers. Feeds the Sites Overview cards.

(options: UseContainerPoolStatsOptions = {}) => UseContainerPoolStatsResult

useContainerUnits

Fetches the site's container things from GET /auth/list-things (tag t-container). Returns the raw rows the Sites Overview merge needs — id, type, info.container, info.poolConfig, and the container status under `last.snap.stats.…

(options: UseContainerUnitsOptions = {}) => UseContainerUnitsResult

useDashboardDateRange

Owns the single source of truth for the dashboard's date-range picker. Pass start / end from the return value into every data hook on the page (useHashrateChartData, useConsumptionChartData, the export, etc.) so they refetch in loc…

(options: UseDashboardDateRangeOptions = {}) => UseDashboardDateRangeReturn

useDashboardExport

Builds CSV / JSON downloads from the dashboard's already-cached TanStack Query data. Does NOT trigger refetches — the export is exactly what the user is looking at when they click the button.

(options: UseDashboardExportOptions) => UseDashboardExportReturn

useDashboardTimeRange

Tiny piece of shared state for the dashboard's timeline selector. Owns the current timeline value plus the canonical option list. The chart hooks (useHashrateChartData, etc.) consume timeline as a prop.

(opts: UseDashboardTimeRangeOptions = {}) => DashboardTimeRange

useDeviceAction

Entry point for wiring device-control UI (reboot, power mode, LED, socket switches, ...) into the voting/approval workflow: components build a typed submission with the foundation's device-action builders and queue it here. Submission and…

() => UseDeviceActionResult

useGetAvailableDevices

Pure projector turning a flat device list (or the /auth/list-things nested shape) into the two type-buckets the device-explorer toolbar needs.

({ data, }: UseGetAvailableDevicesOptions) => AvailableDevices

useHashrateChartData

Multi-series hashrate chart data — Mining OS (miner tail-log) plus an Aggr Pool rollup and one line per individual pool (drawn from the paginated type=minerpool, key=stats-history ext-data feed).

(params: UseHashrateChartDataParams) => HashrateChartResult

useLiveActions

Polls GET /auth/actions every 5 s (voting, ready, executing, done). Partitions results into the current user's actions vs others', and gates othersVoting behind the actions:w permission.

() => LiveActionsData

useMinerDevices

Fetches miner devices from GET /auth/list-things (tag t-miner) in the nested shape the devkit Miner Explorer expects. Prefer this over useMiners when feeding the devkit — only the nested info.poolConfig id can resolve pool na…

(options: UseMinerDevicesOptions = {}) => UseMinerDevicesResult

useMiners

Fetches miners with their assigned poolConfig from GET /auth/miners. Unwraps the paginated response envelope and returns the page rows for the Miner Explorer table plus the site-wide totalCount; row shaping (status mapping, pool labe…

(options: UseMinersOptions = {}) => UseMinersResult

usePendingActions

Fetches submitted actions from GET /auth/actions — the server-side voting/approval queue (distinct from the local actionsStore staging buffer). Vote/cancel mutations invalidate this query's key.

(options: UsePendingActionsOptions = {}) => UsePendingActionsResult

usePoolBalanceHistory

Fetches per-pool revenue/hashrate history from GET /auth/pools/:pool/balance-history. The query is disabled until a non-empty pool is supplied.

(pool: string, options: UsePoolBalanceHistoryOptions = {}) => UsePoolBalanceHistoryResult

usePoolConfigsData

Fetches raw pool configurations from GET /auth/configs/pool. Returns the untransformed rows in the &#123; data, isLoading, error &#125; shape the devkit usePoolConfigs transform consumes — keeping tag/endpoint parsing in the component layer pe…

(options: UsePoolConfigsDataOptions = {}) => UsePoolConfigsDataResult

usePoolManagerDashboard

Composes the Pool Manager dashboard view-model:

(options: UsePoolManagerDashboardOptions = {}) => UsePoolManagerDashboardResult

usePoolRows

Returns one row per configured mining pool, ready for the &lt;MiningPoolsPanel /&gt; table. Reuses the same TanStack queryKey as usePoolStats so subscribing here doesn't trigger an extra fetch — both hooks share the cache entry.

(options: UsePoolRowsOptions = {}) => UsePoolRowsResult

usePools

Fetches aggregated pools from GET /auth/pools (hashrate / workers / balance / revenue / summary). Feeds the Dashboard pool panel — distinct from usePoolConfigsData (/auth/configs/pool), which drives the editable Pools list.

(options: UsePoolsOptions = {}) => UsePoolsResult

usePoolStats

Aggregates per-pool worker counts and hashrate from GET /auth/ext-data?type=minerpool&query=&#123;"key":"stats"&#125;. Returns the total, online, and mismatch triplets and the summed hashratePhs shaped for `<HeaderMinersBox poolTotal/poolO…

(options: UsePoolStatsOptions = {}) => PoolStats

usePowerModeTimelineData

TanStack Query hook returning power-mode/status samples shaped for &lt;PowerModeTimelineChart data=&#123;...&#125; /&gt;.

(params: UsePowerModeTimelineDataParams) => UseQueryResult<PowerModeTimelineEntry[], Error>

useSiteConsumption

Projects the freshest consumption sample out of the dashboard's existing tail-log query for the header stats strip (&lt;HeaderConsumptionBox /&gt;).

(params: UseConsumptionChartDataParams) => SiteConsumption

useSiteConsumptionChartData

Site-level power consumption time-series, shaped for &lt;LineChartCard /&gt;. Reads site_power_w from the t-powermeter-tagged tail-log (same source the header's useSitePowerMeter snapshot uses), converts W → MW, and emits `highlightedVal…

(params: UseSiteConsumptionChartDataParams) => SiteConsumptionChartResult

useSiteContainerCapacity

Reads the aggregated nominal miner capacity across the site's containers — i.e. the maximum number of miners the facility was designed to host. Used as the "denominator" of the &lt;HeaderMinersBox /&gt; row: e.g. the 2,188 in 158 / 2,188.

(options: UseSiteContainerCapacityOptions = {}) => SiteContainerCapacity

useSiteDetailMiners

Resolves the container that backs selectedUnitId, then returns the subset of miner devices assigned to that container. Both underlying queries are already issued by the PoolManager page, so React Query deduplicates them — no extra networ…

(selectedUnitId: string | null) => UseSiteDetailMinersResult

useSiteEfficiency

Derives W/TH/s from the latest consumption + hashrate samples. Reuses both existing tail-log queries (no extra fetch) so the header efficiency box stays in step with the corresponding chart cards. Pass powerW to swap the numerator in (e.…

(params: UseSiteEfficiencyParams) => SiteEfficiency

useSiteHashrate

Projects the freshest hashrate sample from the dashboard's tail-log query. Shares the TanStack queryKey with useHashrateChartData, so subscribing here does NOT trigger an extra fetch — both hooks read the same cache entry.

(params: UseSiteHashrateParams) => SiteHashrate

useSiteMinerCounts

Counts active miners by status for the header &lt;HeaderMinersBox /&gt;. Hits /auth/list-things?status=1 with a tight projection (id, type, last.status only) so the response stays small even on big sites.

(options: UseSiteMinerCountsOptions = {}) => UseQueryResult<SiteMinerCounts, Error>

useSiteMinerStats

Live miner-status breakdown for the header &lt;HeaderMinersBox /&gt; strip. Reads the realtime tail-log (key=stat-rtd, type=miner, tag=t-miner) and projects four aggregate counts. Values reflect what is reporting right now, not the full inve…

(options: UseSiteMinerStatsOptions = {}) => SiteMinerStats

useSitePowerMeter

Site-level power reading for the header's &lt;HeaderConsumptionBox /&gt;. Reads the freshest snapshot from a t-powermeter-tagged thing at info.pos = 'site'; falls back to a t-container-tagged thing if no powermeter is configured (matches…

(options: UseSitePowerMeterOptions = {}) => SitePowerMeter

useSitesOverview

Composes the Sites Overview dataset from three sources:

(options: UseSitesOverviewOptions = {}) => UseSitesOverviewResult

useSitesOverviewData

Projects raw site-overview rows into a &lt;PoolManagerSitesOverview /&gt;- ready shape: each container gets its per-container hashrate (in MH/s), an attached pool-stats row keyed by container id, and a mining / offline status derived from…

({ units: rawUnits, poolStats, isLoading, tailLogItem, }: UseSitesOverviewDataOptions) => UseSitesOverviewDataResult

useSiteStatusLive

Polls GET /auth/site/status/live?overwriteCache=true every 5s for the composite site snapshot (hashrate, power, efficiency, miner / alert / pool counts). Returns the raw typed payload for a hook or component to shape into dashboard cards.

(options: UseSiteStatusLiveOptions = {}) => UseSiteStatusLiveResult

useSubmitPendingActions

Submits the locally-staged actionsStore queue to the voting/approval workflow. This is the network half of the write flow: the devkit modals only enqueue (setAddPendingSubmissionAction); nothing posted to /auth/actions until this h…

() => UseSubmitPendingActionsResult

useSubmitSingleAction

Submits a single action from the staged queue by its local id. Inspects the 200 response body for embedded errors before treating the call as successful. Removes the action from the queue only on genuine success.

() => UseSubmitSingleActionResult

useVoteOnAction

Casts an approve/reject vote on a pending action via PUT /auth/actions/voting/:id/vote. Invalidates the pool/miner/actions caches on success so the review tray and dashboard reflect the new state. Gated by actions:w.

() => UseVoteOnActionResult

From @tetherto/mdk-react-devkit

useContainerWidgetsData

Site Overview data hook: composes the container inventory + realtime miner aggregate (useContainerWidgets) with the per-model thresholds (useContainerSettings) and shapes them into th…

(options?: UseContainerWidgetsOptions) => UseContainerWidgetsDataResult

usePoolConfigs

Transforms raw pool-configuration rows from the host's API into PoolSummary objects for Pool Manager components.

({ data, isLoading, error, }: Partial<UsePoolConfigsOptions>) => UsePoolConfigsResult

useSiteOverviewDetailsData

Composes the per-site overview view-model: pools, performance series, and recent activity.

(unit?: UnitData | undefined, options?: SiteOverviewDetailsDataOptions) => UseSiteOverviewDetailsDataResult

On this page