Manual

If you have your own way of managing auth, you can manually sign in/sign out users by implementing the following:

import { useAppContext } from '../Context' //If you're in a subfolder, adjust the path

...

//import signIn and signOut from the context
const { signIn, signOut, currentUser } = useAppContext() 

...

signIn(accessToken) //Sign in with a JWT accessToken

...

signOut() //Sign out

...

const isAuthenticated = (currentUser != null)
if (isAuthenticated) {
    const firstName = currentUser.firstName
    const userId = currentUser.userId
}

These functions automatically manage state throughout your app across all open tabs, components, and pages.

Last updated