adapter property

dynamic get adapter

Allow usage of different types of adapters or a custom adapter to make Keycloak work in different environments. The following options are supported:

  • default - Use default APIs that are available in browsers.
  • cordova - Use a WebView in Cordova.
  • cordova-native - Use Cordova native APIs, this is recommended over cordova. It's also possible to pass in a custom adapter for the environment you are running Keycloak in. In order to do so extend the KeycloakAdapter interface and implement the methods that are defined there. For example:
import Keycloak, { KeycloakAdapter } from 'keycloak-js';
// Implement the 'KeycloakAdapter' interface so that all required methods are guaranteed to be present.
const MyCustomAdapter: KeycloakAdapter = {
login(options) {
// Write your own implementation here.
}
// The other methods go here...
};
const keycloak = new Keycloak();
keycloak.init({
adapter: MyCustomAdapter,
});

Implementation

external dynamic /*'default'|'cordova'|'cordova-native'|KeycloakAdapter*/
    get adapter;
set adapter (dynamic v)

Implementation

external set adapter(
    dynamic /*'default'|'cordova'|'cordova-native'|KeycloakAdapter*/ v);