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.
| Hook | Purpose | Returns |
|---|---|---|
useNats | NATS pub/sub/request over the bridge | { connected, publish, subscribe, request, orgId, userId } |
useKhalAuth | Current user + org + role | KhalAuth | null |
useService | Call your pack’s own backend service | { connected, transport, request, publish, subscribe, ports, getUrl } |
Import
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.