useAuth

Simplified hook for basic authentication state.
1import { useAuth } from '@avalabs/avacloud-waas-react';
2
3function AuthComponent() {
4 const {
5 isAuthenticated,
6 login,
7 logout
8 } = useAuth();
9
10 return (
11 <div>
12 {isAuthenticated ? (
13 <button onClick={logout}>Logout</button>
14 ) : (
15 <button onClick={login}>Login</button>
16 )}
17 </div>
18 );
19}

Returns

  • isAuthenticated : boolean - Current authentication status
  • login : () => Promise - Trigger login flow
  • logout : () => Promise - Trigger logout flow

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