Keycloak typescript adapter
npm install @react-keycloak/keycloak-ts> Typescript porting of Keycloak javascript client




---
- Install
- Getting Started
- Create a custom KeycloakAdapter
- Setup Keycloak instance
- Contributing
- License
---
``sh`
yarn add @react-keycloak/keycloak-ts
or
`sh`
npm install @react-keycloak/keycloak-ts
KeycloakTS provides a porting of the original Keycloak javascript adapter to allow better extensibility and usage on different platform by using custom adapters.
Create a class which implements the KeycloakAdapter interface
`ts
import type { KeycloakAdapter } from '@react-keycloak/keycloak-ts';
// Wrap everything inside ReactNativeKeycloakProvider
class MyCustomAdapter implements KeycloakAdapter {
...
};
export default MyCustomAdapter;
`
`ts
import { KeycloakClient } from '@react-keycloak/keycloak-ts';
import MyCustomAdapter from './adapter.ts';
// Setup Keycloak client as needed
// Pass initialization options as required
const keycloak = new KeycloakClient({
url: 'http://keycloak-server/auth',
realm: 'kc-realm',
clientId: 'web'
});
// Call init passing a custom adapter
keycloak.init({
adapter: MyCustomAdapter,
});
export default keycloak;
``
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT