AuthContext API
AuthContextType
Main authentication context interface for both authentication-only and Web3 integrations.AuthState
Authentication state object containing user session information.AuthUser
User profile information returned from Civic Auth.Methods
signIn()
Initiates the OAuth2 authentication flow.
Returns: Promise<void>
Example:
signOut()
Signs out the user and clears the session.
Returns: Promise<void>
Example:
Web3Client API
Web3Client is only available when using the Web3 Wallet Integration.
Web3Client Interface
Main interface for blockchain operations.SolanaWeb3Client Interface
Solana-specific wallet operations.Methods
createWallets()
Creates embedded wallets for the authenticated user.
Returns: Promise<Wallets | null>
Requirements:
- User must be authenticated
- Valid ID token required
sendTransaction(address, amount)
Sends SOL to a recipient address. Handles transaction creation, signing, and broadcasting.
Parameters:
address(string): Recipient’s public keyamount(number): Amount in SOL
Promise<string> - Transaction hash
Example:
signTransaction(transaction, reason)
Signs a custom Solana transaction.
Parameters:
transaction(Transaction): Solana transaction objectreason(string): Human-readable reason shown to user
Promise<Buffer> - Transaction signature
Example:
signMessage(message, reason)
Signs an arbitrary message for verification purposes.
Parameters:
message(string): Message to signreason(string): Human-readable reason shown to user
Promise<string> - Base64 encoded signature
Example:
getBalance()
Gets the current SOL balance of the wallet.
Returns: Promise<number | undefined> - Balance in SOL
Example:
disconnect()
Disconnects the Web3 client and cleans up resources.
Returns: Promise<void>
Example:
Configuration Objects
CivicWeb3ClientConfig
Configuration for Web3 client initialization.AuthRequestConfig
Configuration for OAuth2 authentication.Hooks
useWeb3Client(config, idToken)
React hook for initializing and managing Web3 client.
Parameters:
config(CivicWeb3ClientConfig): Web3 configurationidToken(string | undefined): User’s ID token from authentication
Web3Client | null | undefined
Example:
Error Handling
Common Error Types
Authentication Errors
Web3 Errors
Wallet Creation Errors
TypeScript Support
All interfaces and types are fully typed for TypeScript projects. Import types from the respective packages:Migration Guide
From Authentication Only to Web3
To upgrade from authentication-only to Web3 integration:-
Install additional packages:
-
Add Web3 configuration:
-
Initialize Web3 client:
- Complete native setup as described in Web3 Wallet Integration
Breaking Changes
- None currently, as Web3 integration is additive to authentication-only functionality
Support
- Documentation Issues: GitHub Issues
- Developer Community: Slack Channel
- Example Code: GitHub Repository

