Skip to content

useIsAuthenticated

Import

import useIsAuthenticated from 'react-auth-kit/hooks/useIsAuthenticated';

Function Signature

useIsAuthenticated(): () => booleanIs Authenticated, React Hook

Call the hook to know if the user is authenticated or not

This uses the context data to determine whether the user is authenticated or not.

Returns

fn => (): boolean

Example

import useIsAuthenticated from 'react-auth-kit/hooks/useIsAuthenticated'

const Component = () => {
 const isAuthenticated = useIsAuthenticated()
 if (isAuthenticated()) {
   // user authenticated - do somthing
 }
 else {
   // user not authenticated
 }

Throws

AuthError - Thrown if the Hook is used outside the Provider Scope.

Defined in

hooks/useIsAuthenticated.ts


— 🔑 —

React Auth Kit is MIT License code