Skip to content

Latest commit

History

History
27 lines (19 loc) 路 645 Bytes

WITHAUTH.md

File metadata and controls

27 lines (19 loc) 路 645 Bytes

Hooks

OIDC React comes with a HOC withAuth! withAuth is a great way, much better then using our Consumer.

withAuth

withAuth returns a component wrapped in authContext. Let's look at an example of use.

import { withAuth } from 'oidc-react';

class Hello extends React.PureComponent<{}, {}> {
  render() {
    return <p>Hello {this.props.authData.profile.name}!</p>;
  }
}

export default withAuth(Hello);

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

It should be as easy as that!