Keycloakify
HomeGitHubStorybookAlternative to keycloak-js
  • Documentation
  • Release Notes & Upgrade Instructions
  • FAQ
  • Frequently Asked Questions
  • How does Keycloakify work?
  • It works in Storybook but not in Keycloak
  • There is too much info exposed in window.kcContext
  • How do I identify the page to customize?
  • Can I use react-hooks-form?
  • I can't find what I need in the kcContext
  • How do I add extra pages?
  • How can I access Realm Attributes?
  • How can I redirect the user to Login/Register?
  • Errors in Keycloak Log
  • Why do I get reCaptcha warnings?
  • My Realm Overrides Translations do not apply
  • Validating the password in login-update-password.ftl page
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

I can't find what I need in the kcContext

Extending the KcContext type definition

Last updated 4 months ago

Was this helpful?

The kcContext type definitions only includes what the default pages actually uses.

However, at runtime there is much more information in the kcContext that what TypeScript is aware of!

A common scenario is when you want, on the register page to enable sign-up via Google or Facebook but the kcContext.social object isn't defined: \

Here is how you would go about addressing this usecase for this particular usecase:

First step is to extend the KcContext type:

Second step is to augment the KcContext base mocks for testing in Storybook:

Then you can use the kcContext.social object in the register page just as you would on the login page:

Declaring that there is a social property on the kcContext of the register page and this social object is of the same type as the one present on the login page.
We say that the social object of the mock of the register page kcContext is the same as the social object on the mock of the login page kcContext
Applying the same socialProviderNode on the register page as the one applied in the login page.
kcContext.social not defined in the KcContext type on the register page.