Skip to main content
The SDK gives your pack’s frontend three React hooks. useNats for pub/sub and request/reply across packs. useKhalAuth to read the authenticated user. useService to call your own pack’s backend. Everything else is built on top of these.
HookPurposeReturns
useNatsNATS pub/sub/request over the bridge{ connected, publish, subscribe, request, orgId, userId }
useKhalAuthCurrent user + org + roleKhalAuth | null
useServiceCall your pack’s own backend service{ connected, transport, request, publish, subscribe, ports, getUrl }

Import

import { useNats, useKhalAuth, useService } from '@khal-os/sdk/app';

Explore each hook

useNats

Publish, subscribe, and request across packs over NATS.

useKhalAuth

Read the signed-in user’s id, org, role, and permissions.

useService

Call your pack’s backend with a transport-agnostic client.
All three hooks are client-side ('use client'). Call them from React components mounted inside a KhalAuthProvider — the desktop shell provides this.