Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 573 Bytes

HOOKS.md

File metadata and controls

23 lines (15 loc) · 573 Bytes

Hooks

OIDC React comes with hooks! Hooks are a great way, much better then using our Consumer.

useAuth

useAuth returns the same as our authContext. Let's look at an example of use.

import { useAuth } from 'oidc-react';

export default () => {
  const auth = useAuth();

  return (
    <p>Hello {auth.profile.name}!</p>
  );
}

The example above uses id_token object (profile) and displays the name of the user.

It should be as easy as that!