This post will show you how to secure a React app using RedHat SSO (upstream Keycloak). In this case, OpenID-connect is my identity provider.
Install the official Keycloak js adapter
npm i keycloak-js --save Add host and port information to the client; in my case, it’s localhost:9000
In App.js, add a JavaScript object with the required configuration; you will find these configurations under Clients->Installation.
//keycloak init options const initOptions = { url: "https://localhost:8080/auth", realm: "test", clientId: "react-app", onLoad: "login-required" }; By default, to authenticate, you need to call the login function.