Skip to main content

Securing a website route / component

You may want to prevent rendering of some part of UI, or a route, when there's no session. To achieve that, pass requireAuth={true} as a prop to SessionAuth:

Do you use react-router-dom?

If you pass requireAuth={true}, you have to pass function to redirectToLogin prop, which will redirect the user to where they might log in.