useAvaCloudWallet

The primary hook for handling authentication and basic wallet functionality.
1import { useAvaCloudWallet } from '@avalabs/avacloud-waas-react';
2
3function WalletComponent() {
4 const {
5 isAuthenticated,
6 isLoading,
7 user,
8 wallet,
9 login,
10 logout,
11 addAccount,
12 } = useAvaCloudWallet();
13
14 if (isLoading) {
15 return <div>Loading...</div>;
16 }
17
18 return (
19 <div>
20 {isAuthenticated ? (
21 <button onClick={logout}>Logout</button>
22 ) : (
23 <button onClick={login}>Login</button>
24 )}
25 </div>
26 );
27}

Returns

  • isAuthenticated : boolean - Current authentication status
  • isLoading : boolean - Loading state of authentication
  • user : User | null - User information
  • wallet : Wallet | null - Current wallet information
  • login : () => Promise - Trigger login flow
  • logout : () => Promise - Trigger logout flow
  • addAccount : () => Promise - Add a new account to the wallet

For any additional questions, please view our other knowledge base articles or contact a support team member via the chat button. Examples are for illustrative purposes only.

Learn More About AvaCloud | Download Case Studies | Schedule an AvaCloud Demo