React Hooks

Authentication hooks from @emblemvault/emblem-auth-react for accessing auth state and actions.

useEmblemAuth Hook

Access authentication state and actions. Returns all wallet info, session data, and methods to control authentication flow.

🔌 Provider Required

This hook must be used within EmblemAuthProvider. If used outside the provider, it will throw an error.

Basic Usage

TS
MyComponent.tsx
Loading...

Return Values

PropertyTypeDescription
sessionAuthSession | nullCurrent auth session with user data & tokens
isAuthenticatedbooleanWhether user is authenticated
isLoadingbooleanLoading state during initialization/auth
errorError | nullAuthentication error if any
vaultInfoVaultInfo | nullVault details (addresses, metadata)
vaultIdstring | nullUser's vault ID
walletAddressstring | nullPrimary wallet address (EVM or Solana)
visitorIdstring | nullAnonymous visitor tracking ID
openAuthModal() => Promise<void>Open authentication modal
logout() => voidLogout and clear session
refreshSession() => Promise<AuthSession | null>Refresh auth token
authSDKEmblemAuthSDK | nullDirect access to underlying SDK

Session Refresh

TS
TokenRefresher.tsx
Loading...

Direct SDK Access

For advanced use cases, access the underlying EmblemAuthSDK instance directly:

TS
AdvancedComponent.tsx
Loading...

AuthSession Type

user: AuthUser
authToken: string
refreshToken?: string
expiresAt: number
appId: string
scope?: string

VaultInfo Type

vaultId: string
evmAddress?: string
solanaAddress?: string
hederaAccountId?: string
createdAt?: string
metadata?: Record