Does anyone know how to restrict access to particular routes in react-router? I want to check if the user is logged in before allowing access to a particular route. I though
usually a logged in user will be granted a token, and uses this token for any communication with server. What we usually do is define a root page, and things build on top of that page. this root page does localisation, authentication and other configurations for you.
here's an example
Routes = (
);
on your root page, check for token null or authenticate the token with server to see if user is valid login.
hope this helps :)