AvaCloud
UsageHooks

useAvaCloudWallet

import { useAvaCloudWallet } from '@avalabs/avacloud-waas-react';
 
function WalletComponent() {
  const {
    isAuthenticated,
    isLoading,
    user,
    wallet,
    login,
    logout,
    addAccount,
  } = useAvaCloudWallet();
  
  if (isLoading) {
    return <div>Loading...</div>;
  }
 
  return (
    <div>
      {isAuthenticated ? (
        <button onClick={logout}>Logout</button>
      ) : (
        <button onClick={login}>Login</button>
      )}
    </div>
  );
}

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

If you need more help, explore our other articles or reach out to our support team via chat or email support@avacloud.io. All examples provided are for demonstration purposes only.

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

On this page