1.2.4 • Published 5 years ago
@gabrielgvl/jwt_auth_react
Licence
MIT
Version
1.2.4
Deps
2
Size
16 kB
Vulns
0
Weekly
0
Jwt Auth
Usage example
Provider
Wrap your application with the provider
ReactDOM.render(
<JwtAuthProvider keyPrefix="YOUR APP KEY">
<App />
</JwtAuthProvider>,
document.getElementById('root'),
);
- Hooks
import useJwtAuth from '@gabrielgvl/jwt_auth_react';
const MyComponent = () => {
const { handleLogin, logIn, logOut, userInfo } = useJwtAuth();
}
logIn(token)- Passes response jwt token to storagelogOut()- Remove token from storageisLoggedIn- Check if token is in storageuserInfo- Retrieves decoded user info from token