@hyperauth/react
HyperAuthProvider
HyperAuthClient and makes it available to the component tree via useHyperAuth.
Props
Behavior
- Calls
createClient(config)once on mount inside auseEffect. - Sets
statusto'initializing'during setup,'ready'on success,'error'on failure. - Parses
projectIdas a UCAN policy and exposes it aspolicyon the context. - Reacts to
chainprop changes without restarting the worker. - Calls
client.close()on unmount. - Uses a
useRefguard to prevent double-initialization in React Strict Mode.
The provider spawns browser workers at mount, so it must render on the client. In server-rendered frameworks such as Next.js App Router, import it through
next/dynamic with ssr: false. See Next.js App Router for a full example.useHyperAuth
HyperAuthContext value. Throws ClientStateError if called outside HyperAuthProvider.
Signature
Return type
HyperAuthStatus
useRegistration
Signature
Return type
RegistrationPhase
RegistrationStep
The 12 step labels, in order:
IdentityState
Populated after step 2 ('generating-identity'). Available via identity before result is set.
RegistrationOutcome
Populated on successful completion (phase === 'complete').
cspManifest
Shape
cspManifestString
cspManifest serialized as a single CSP header value. Use this when you compose the CSP at request time, for example from a Next.js proxy or middleware.
Signature
Example
cspManifest does not include style-src. Next.js Server Components, next-themes, and framer-motion inject inline <style> tags; the standard workaround is to add style-src 'self' 'unsafe-inline' alongside the SDK directives.