Configuring React Application with Keycloak
Introduction In the previous section, we secured a .NET API and validated access using Keycloak. Now we will integrate a React client so users can authenticate with the same Keycloack instance and ...

Source: DEV Community
Introduction In the previous section, we secured a .NET API and validated access using Keycloak. Now we will integrate a React client so users can authenticate with the same Keycloack instance and call protected API endpoints from the browser. Note: This article assumes that you have a basic knowledge in React components, contexts and hooks This section contains the following: Add React service to Docker Compose Configure the Keycloak client for React Configure the audience mapper Install dependencies and configure Keycloak in React Create the Keycloak provider and context Add a simple token service Protect routes in React Add login, logout, and profile actions Testing the authentication and authorization Conclusion Add the React service in Docker Compose If your compose file does not already include the React app, add a frontend service: services: reactapp: build: context: reactapp.client dockerfile: Dockerfile ports: - "3000:3000" depends_on: - backend - keycloak networks: - app-netw