Socket
Book a DemoInstallSign in
Socket

react-keycloak-context

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

react-keycloak-context

A Keycloak provider for React

unpublished
Source
npmnpm
Version
1.0.9
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

react-keycloak-context

package version package downloads standard-readme compliant package license make a pull request

A Keycloak provider for React

Table of Contents

Usage

import React from 'react'
import App, { Container } from 'next/app'
import Head from 'next/head'

import {
  Provider as KeycloakProvider,
  Consumer as KeycloakConsumer
} from 'react-keycloak-context'

const keycloakConfig = {
  realm: 'master',
  clientId: 'example',
  url: 'https://foobarbaz.com/auth',
  'ssl-required': 'external',
  'public-client': true,
  'confidential-port': 0
}

class Example extends App {
  static async getInitialProps({ Component, ctx }) {
    let pageProps = {}

    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps({ ...ctx })
    }

    return { pageProps }
  }

  handleKeycloakInit = kc => {
    console.log('keycloak', kc)
  }

  render() {
    const { Component, pageProps } = this.props

    return (
      <Container>
        <Head>
          <title>Example project</title>
        </Head>

        <KeycloakProvider
          initOptions= {{
            onLoad: 'login-required',
            promiseType: 'native'
          }}
          config={keycloakConfig}
          tokenKey={'kc-token'}
          refreshTokenKey={'kc-refresh'}
          onInit={this.handleKeycloakInit}
        >
          <KeycloakConsumer>
            {kc => <Component keycloak={kc} {...pageProps} />}
          </KeycloakConsumer>
        </KeycloakProvider>
      </Container>
    )
  }
}

export default Example

Install

This project uses node and npm.

$ npm install react-keycloak-context
$ # OR
$ yarn add react-keycloak-context

Contribute

  • Fork it and create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am "Add some feature"
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

MIT © [[object Object]]([object Object])

Keywords

react

FAQs

Package last updated on 24 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts