useKhalAuth returns the current authenticated user. The platform handles sign-in — your pack reads who’s here and renders accordingly.
Signature
null while no KhalAuthProvider is mounted or the user is unauthenticated. Once authenticated, returns a KhalAuth object.
The KhalAuth shape
Stable user identifier. Use it as a subject segment when you need per-user addressing.
Organization the user is signed in under. All NATS subjects your pack uses should be scoped by this.
Normalized role slug. Canonical values are
member, platform-dev, platform-admin, platform-owner.Flat list of permission strings granted to the current role. Check membership with
permissions.includes('some:permission').true while the provider is still resolving the session. Render a loading state until this flips to false.The platform handles sign-in. Your pack reads the authenticated user — it does not trigger or clear the session itself.
Typical use — gate rendering on loading + role
Scoping NATS subjects
useNats already syncs orgId and userId from useKhalAuth internally, so most code pulls them straight from useNats. Reach for useKhalAuth when you need role or permissions, or when the component doesn’t already use NATS.
Permissions
permissions is a pre-computed allow-list for the current role. Check it with .includes(...):
/sdk/permissions — TBD in a later wish.
What it does not expose
- No JWT, no session token, no refresh plumbing.
- No
signOutmethod — use the desktop shell’s sign-out UI. - No auth provider internals — your pack should not care whether the shell runs on web or desktop.
KhalAuth, you almost certainly need to get it through a service call, not auth state.
What’s next
useNats
Publish, subscribe, and request/reply on the platform NATS bridge.
useService
Call into your pack’s own backend service.