Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 558 Bytes

HOOKS.md

File metadata and controls

25 lines (17 loc) · 558 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!