Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2020 08:45
What would you like to do?
Keycloak react private route that accepts a route with params, possible answer to this question
<PrivateRoute exact path="/props-through-render" render={(props) => <PropsPage {...props} title={`Props through render`} />} />
import React from 'react';
import { Route } from 'react-router-dom';
import { withKeycloak } from '@react-keycloak/web'
function PrivateRoute({ }) {
return rest.keycloakInitialized && <Route {} render={props => (
rest.keycloak.authenticated ? rest.render(props) : rest.keycloak.login()
)} />
export default withKeycloak(PrivateRoute)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment