Programatically login user with useAuth0 hook and react

@auth0/auth0-react
1.7.0
Node v14.15.1

Hi, currently I am using Auth0 with the useAuth0 hook in a React app in conjunction with the Auth0 login page to log the user in. I can then grab the token and check for authenticated using the hook in my app and it all works great.

const { getAccessTokenSilently, isLoading, isAuthenticated, error, user } = useAuth0()

Now I want to programatically log the user in after I post to a signup method which exists on my back-end. I make the API call to create the user to my back-end which calls the Auth0 Api and creates the user. Now this works and the user can now sign in with their new credentials. But I was wondering if was possible to log the user in automatically at this point as they have just created their account. I have the Auth0 token I’m just not sure where to put it. I don’t see anything in the cookies or localStorage so I’m not sure where I should store this token so that useAuth0 hook can recognize and parse it. Do I need to use the full javascript SDK as opposed to just this hook? Or is there a way I can inject this token somewhere so that Auth0 recognizes it.

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!