npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jabardigitalservice/nuxt-module-keycloak

v0.0.1

Published

Keycloak SSO reusable module

Readme

@jabardigitalservice/nuxt-module-keycloak

Pluggable NuxtJS module for Keycloak SSO functionality.

Features

  • Dynamic vuex module registration under user-defined namespace.
  • Inject Keycloak instance into Nuxt context.
  • Auto-register middleware for Keycloak initiation, authentication, and refresh token. Middleware can either be used globally, per layout, or per route.

Available Options

Options can be set inside module definition in nuxt.config.js or by using corresponding .env keys. | Name or .env key | Type | Attribute | Default | Description | | --- | --- | --- | --- | ---- | | keycloakUrl, KEYCLOAK_URL | string | | | Keycloak auth URL in which authentication is performed. | | redirectUri, KEYCLOAK_REDIRECT_URL | string | | | Application URL to be redirected onto after authentication is performed and validated by keycloak. | | realm, KEYCLOAK_REALM | string | | | Keycloak realm. | | clientId, KEYCLOAK_CLIENT_ID | string | | | Keycloak client ID. | | refreshInterval, KEYCLOAK_INTERVAL | number | optional | 60000 | Keycloak refresh token interval in milliseconds. | | namespace, KEYCLOAK_NAMESPACE | string | optional | keycloak | Keycloak nuxt module namespace. Used as middleware name, vuex module namespace, and injected context property name. |

How to use

  1. Go to root folder of your Nuxt project and install this package.

    yarn add @jabardigitalservice/nuxt-module-keycloak
    
    # using NPM
    npm install @jabardigitalservice/nuxt-module-keycloak
  2. Assign module in nuxt.config.js

    export default {
      modules: [
        ['@jabardigitalservice/nuxt-module-keycloak', {
          namespace: 'keycloak',
          refreshInterval: 60000,
          clientId: KEYCLOAK_CLIENT_ID,
          realm: KEYCLOAK_REALM,
          keycloakUrl: 'https://your-keycloak-domain.app',
          redirectUri: 'https://your-webpage.app',
        }]
      ]
    }
  3. Assign configured namespace as middleware value.

    // set globally in nuxt.config.js
    export default {
      router: {
        middleware: ['keycloak']
      }
    }
    
    // or in layout, e.g layout/default.vue
    export default {
      middleware: ['keycloak']
    }
    
    // or in page, e.g pages/index.vue
    export default {
      middleware: ['keycloak']
    }

Injected property/context/module

  • Use this.$keycloak (or this.$<namespace>) to access Keycloak instance.
    // inside Vue component
    export default {
      methods: {
        logout () {
          return this.$keycloak.logout()
        }
      }
    }
  • Injected instance can also be accessed using Nuxt context. Note: property name is based on namespace option.
    // inside your nuxt plugin, e.g plugins/some-fn.js
    export default (context) => {
      const keycloak = context.$keycloak;
    }
    
    // shorthand
    export default ({ $keycloak }) => {}
  • Keycloak Vuex module is registered under namespace.
    // inside Vue component
    export default {
      computed: {
        ...mapState('keycloak', [
          'user',
          'roles',
          'permissions'
        ])
      }
    }

Caveats

Ensure your store folder at least consist index.js, since Vuex would only be initiated by Nuxt using this way.