How to use JWT authentication system ?
Note:
The uko template uses the firebase authentication system by default.
-
Step-1 : Open the
src/App.jsx
file then import the AuthProvider fromcontexts/jwtContext
and wrap the App component with it. -
Step-2 : Open the
src/hooks/useAuth.js
file. Thereupon, import the AuthContext fromcontexts/jwtContext
then pass AuthContext as a argument in useContext hook. -
Step-3 : Call the useAuth hook inside AuthGuard, GuestGuard components, Login, Register page etc.
Step 1
_11import { AuthProvider } from "contexts/jwtContext";_11_11const App = () => {_11 return (_11 <AuthProvider>_11 <Component />_11 </AuthProvider>_11 );_11};_11_11export default App;
Step 2
_10import { AuthContext } from "contexts/jwtContext";_10_10const useAuth = () => useContext(AuthContext);_10export default useAuth;
Step 3
How to delete from app ?
- Delete the
jwtContext.jsx
file fromsrc/contexts
folder - In addition, if you use this, remove it from the
src/hooks/useAuth.js
file.