How to use Auth0 ?
Note: The essence template uses the firebase authentication system by default.
-
Step-1 : Sign up for an account on Auth0 (opens in a new tab). After that, get the
client id and domainfrom the dashboard and put them in the.envfile. -
Step-2 : Open the
src/hooks/useAuth.jsfile. Thereupon, import the AuthContext fromsrc/contexts/auth0Contextthen pass it as an argument in the useContext hook. -
Step-3 : Call the useAuth hook inside AuthGuard, GuestGuard components, Login, Register page etc.
Step 1
_10REACT_APP_AUTH0_CLIENT_ID= SET YOUR CLIENT ID_10REACT_APP_AUTH0_DOMAIN= SET YOUR DOMAIN
Step 2
_10import { AuthContext } from "contexts/auth0Context";_10_10const useAuth = () => useContext(AuthContext);_10export default useAuth;
Step 3
How to delete from app ?
- Delete the
auth0Context.jsxfile fromsrc/contextsfolder - You should also delete the AuthContext file from the
src/hooks/useAuth.jsfile if you use this. - Also delete the REACT_APP_AUTH0_CLIENT_ID & REACT_APP_AUTH0_DOMAIN from
.envfile. - Uninstall dependecies @auth0/auth0-spa-js (opens in a new tab)