@westyx-nexus/sdk-react. Hooks are the primary surface; the imperative NexusClient is exposed via useNexus() for advanced use cases.
Provider
<NexusProvider config={...}>
Top-level provider that creates the NexusClient instance, performs the blocking initial sync, and connects the SSE stream.
Hooks
useConfig<T>(key: string): T | undefined
Read a config value. Returns the resolved value as T (the wire-decoded JSON), or undefined when the key is absent.
useFlag(key: string, defaultValue?: boolean): boolean
Read a flag value. Returns defaultValue (default false) when the key is absent.
useEvaluateAB(): (keys, userId, attributes?) => Promise<Record<string, boolean>>
Returns a stable callback that evaluates one or more feature flags through the AB Testing endpoint (POST /v1/flags/evaluate-ab). The callback identity is stable across renders unless the underlying client changes.
Unlike useFlag, every invocation hits the network - results are not cached, because targeting rules and rollout buckets depend on the supplied userId / attributes.
useSecret(key: string): string | undefined
Read a secret value. Returns undefined if the client uses a public key, or if the key is missing - it never throws (this is the React-friendly variant of the imperative getSecret).
useSecret always returns undefined.
useNexusSyncedAt(): Date
Last successful sync timestamp. Useful for “last refreshed N seconds ago” UIs.
useNexusSync(): () => Promise<void>
Returns a stable function that triggers a manual sync. Use sparingly - the SDK syncs automatically.
useNexusStreamStatus(): { connected: boolean }
Reactive SSE state. Useful for surfacing a “live” / “polling” indicator.
useNexus(): NexusClient
Escape hatch - returns the underlying NexusClient instance for advanced use. Reads via this client are not reactive (don’t subscribe to the cache). Use the typed hooks above unless you have a specific reason.
Imperative NexusClient (rarely needed)
Error types
NexusInitError is the only one fired during the provider’s normal flow. The hook useSecret is non-throwing (returns undefined); the imperative getSecret throws.
