@reown/appkit-react-native
.
useAppKit()
The primary hook for controlling the modal’s visibility and behavior. Use this hook when you need to programmatically open or close the modal, or when you want to show specific views like the connection screen or account details.
Use Cases
- Opening the modal when a user clicks a “Connect Wallet” button
- Closing the modal after a successful connection
- Opening specific views of the modal (e.g., account view, connect view)
- Disconnecting users from their wallets
- Switching between different blockchain networks
Returns
open
: Function to open the modalclose
: Function to close the modaldisconnect
: Function to disconnect the current sessionswitchNetwork
: Function to switch to a different chain/network
Parameters
You can direct the modal to open to a specific view using theopen
function:
Variable | Description |
---|---|
Connect | Principal view of the modal - default view when disconnected. |
WalletConnect | View with a QR code to scan with wallets and connect via WalletConnect |
Account | User profile - default view when connected. |
Networks | List of available networks - you can select and target a specific network before connecting. |
WhatIsANetwork | ”What is a network” onboarding view. |
WhatIsAWallet | ”What is a wallet” onboarding view. |
useAccount()
The essential hook for accessing wallet connection state and user information. Use this hook whenever you need to know if a user is connected, get their wallet address, or access their account details.
Use Cases
- Displaying the connected wallet address in your UI
- Checking if a user is connected before showing certain features
- Getting user information for authentication flows
- Handling multi-chain scenarios where you need account info for specific chains
- Implementing conditional rendering based on connection status
- Accessing the active blockchain namespace for chain-specific logic
- Getting detailed chain information for network-specific features
Returns
address
: The connected account address (string)chainId
: The chain ID of the currently active connection (number or string)isConnected
: Boolean indicating if a wallet is connected on the current chain/namespacenamespace
: The active namespace (string, e.g., ‘eip155’, ‘solana’, ‘bip122’)chain
: The active chain object with detailed chain information (AppKitNetwork type)
useProvider()
The provider access hook that provides access to the underlying chain-specific provider for the currently active connection. Use this hook when you need to perform direct interactions with the blockchain that go beyond the standard AppKit actions.
By default, useProvider()
returns the provider for the currently active network.
Use Cases
- Accessing the wallet provider for direct blockchain interactions
- Signing transactions and messages with the connected wallet
- Integrating with blockchain-specific libraries (ethers, solana web3, etc.)
- Building custom wallet interactions across different chains
- Performing advanced blockchain operations not covered by AppKit’s standard actions
Returns
provider
: The underlying chain-specific provider for the currently active connectionproviderType
: The type of provider (e.g., ‘eip155’, ‘solana’, ‘bip122’)
useWalletInfo()
The wallet information hook that provides details about the connected wallet. Use this hook when you need to display wallet-specific information, show wallet branding, or implement wallet-specific features.
Use Cases
- Displaying wallet-specific information in your UI
- Implementing wallet-specific features
- Showing wallet icons or branding
- Handling wallet-specific behaviors
- Creating custom wallet selection interfaces
Returns
walletInfo
: Object containing metadata about the connected wallet (name, icon, rdns, id, etc.)
The exact structure of
walletInfo
can be found in the WalletInfo
type definition in packages/common/src/utils/TypeUtil.ts.useAppKitEventSubscription()
The event subscription hook that allows you to listen to modal and wallet events. Use this hook when you need to track user interactions, implement analytics, or respond to specific wallet events in your application.
Use Cases
- Tracking user interactions with the modal
- Implementing analytics for wallet connections
- Creating custom notifications for connection events
- Handling specific wallet events in your application
- Monitoring connection state changes
Parameters
eventType
: The specific event type to subscribe to (e.g., ‘MODAL_OPEN’, ‘CONNECT_SUCCESS’)callback
: Function that is executed when the event is triggered
The full list of event types and their payloads can be found in
AppKitEvents
within packages/core/src/utils/TypeUtil.ts.useAppKitState()
The state management hook that provides real-time access to the modal’s current state and connection status. Use this hook when you need to react to modal state changes or synchronize your UI with the modal’s status.
Use Cases
- Syncing your UI with the modal’s open/closed state
- Creating custom UI elements that respond to modal state changes
- Implementing custom loading states based on modal state
- Checking connection status without accessing account details
- Displaying chain-specific UI based on the connected blockchain
Returns
isOpen
: Boolean indicating if the modal is currently openisLoading
: Boolean indicating if the modal is loadingisConnected
: Boolean indicating if a user is connectedchain
: The connected chain object
useAppKitLogs()
The logging hook that provides access to AppKit’s internal logging system. Use this hook when you need to debug your application, monitor AppKit’s behavior, or export logs for troubleshooting purposes.
Use Cases
- Debugging AppKit behavior and troubleshooting issues
- Monitoring application performance and error tracking
- Exporting logs for support or analysis purposes
- Building custom debugging interfaces for development
- Filtering logs by severity level or time range
Returns
logs
: All logs from AppKit (array of LogEntry objects)errorLogs
: Error-level logs only (array of LogEntry objects)warningLogs
: Warning-level logs only (array of LogEntry objects)infoLogs
: Info-level logs only (array of LogEntry objects)debugLogs
: Debug-level logs only (array of LogEntry objects)getLogsByLevel
: Function to get logs filtered by level (error, warn, info, debug)getRecentLogs
: Function to get recent logs (default: 100, accepts count parameter)exportLogs
: Function to export all logs as JSON stringgetLogsStats
: Function to get logging statistics by levelclearLogs
: Function to clear all logs
This hook requires the
debug
option to be set to true
in your AppKit configuration to capture logs. See the Options documentation for more details.Deprecated Hooks
useDisconnect()
The functionality of useDisconnect
(which previously exposed a disconnect
function) is now available directly from the useAppKit()
hook.