useAuthContext facilitates dealing with authentication in the frontend by encapsulating many logics.
useAuthContext provides the following properties:
authentication: an enum that represents an authentication state of the following : not logged in, verifying authentication, authorized, admin.
setToken, a function that updates the token, you can use it in a login component or a signup component, bear in my mind that it takes care of storing the token in the localstorage so dont worry about that.
token: the current token stored in the localstorage.
user: the current user.
an example to use this hook in a react component is when for example you have a page that requires the user to be authenticated to access, so you use the hook to get the token, if it is null or undefined then you use the Navigate react router component to navigate the user to the login page.
useAuthContext facilitates dealing with authentication in the frontend by encapsulating many logics. useAuthContext provides the following properties: