Skip to content

lcanavesio/react-keycloak-js

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published