Skip to content

Gabrielgvl/jwt_auth_react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 storage
  • logOut() - Remove token from storage
  • isLoggedIn - Check if token is in storage
  • userInfo - Retrieves decoded user info from token

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors