react-keycloak-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

Keycloak login for React

This package use keycloak-js.

It lets you login against a keycloak instance from an React.

Install

npm install react-keycloak-js

How to use

import { KeycloakProvider } from 'react-keycloak-js';

const configKeycloak = {
    url: process.env.REACT_APP_AUTH_APP,
    realm: process.env.REACT_APP_PUBLIC_REALM,
    clientId: process.env.REACT_APP_CLIENT_ID
};

const App = () => (
 <KeycloakProvider keycloakConfig={configKeycloak} initOptions={{ onLoad: 'login-required' }}>
        <AppRoute />
  </KeycloakProvider>
);

# You can use hook useKeycloak()

const { keycloak, authenticated, error, isTokenExpired } = useKeycloak();

Contributing

Feel free to open issues and pull requests. Help from the community is always welcome.

License

MIT


If you found this project to be helpful, please consider buying me a coffee.

buy me a coffee

Package Sidebar

Install

npm i react-keycloak-js

Weekly Downloads

116

Version

1.0.10

License

MIT

Unpacked Size

7.07 kB

Total Files

6

Last publish

Collaborators

  • luxer066