Documentation Index
Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
@dynamic-labs-sdk/react-hooks is a thin React layer over @dynamic-labs-sdk/client. It exposes a <DynamicProvider> and a set of hooks that subscribe to client state and re-render your components when that state changes.
Installation
@dynamic-labs-sdk/client and react as peer dependencies.
Setup
Wrap your app inDynamicProvider and pass the client instance you created with createDynamicClient:
DynamicProvider throws MissingProviderError.
State hooks
These hooks read directly from the client and re-render the component when the underlying state changes. They have no parameters.useUser
Returns the current authenticated user, or null if no user is signed in. Re-renders on sign-in, sign-out, and profile updates.
useWalletAccounts
Returns all wallet accounts on the current session, verified and unverified. Re-renders when accounts are added, removed, or verified.
useSocialAccounts
Returns the user’s linked social accounts (SocialAccount[]). Re-renders when the user’s verified credentials change. Empty array when no user is signed in.
useWalletProviders
Returns the registered wallet providers and their metadata (WalletProviderData[]). Re-renders when a provider is registered, unregistered, or its capabilities change.
useInitStatus
Returns the client’s initialization status: 'uninitialized' | 'in-progress' | 'finished' | 'failed'. Use this to gate UI that depends on SDK methods until the client is ready.
useSessionExpiresAt
Returns the session expiration Date, or null if there is no active session. Re-renders on session updates.
Event hook
useEvent
Subscribes to any client event for the lifetime of the component. The subscription is cleaned up on unmount or when the event name changes. The listener is wrapped in a ref, so updating its identity between renders does not re-subscribe.
userChanged, walletAccountsChanged, tokenChanged, etc.) prefer the dedicated state hooks above — they’re built on top of useEvent and avoid manual subscription bookkeeping.
Client access
useDynamicClient
Returns the DynamicClient instance from context. Throws MissingProviderError if used outside a DynamicProvider. Most code should not need this — use the state hooks for reactive state, and import client functions directly (signMessage, getBalance, etc.) for one-shot calls.
Multiple clients
If your app uses more than one Dynamic client, mount a separateDynamicProvider for each subtree. Hooks resolve the closest provider, so state from one client never leaks into a tree wrapped in a different one.