Feature request: Route guards
See original GitHub issueI’d like to see some form of route guards added, this would check for a truthy statement before attempting to load the component.
This would be useful, with server side guards for the initial load, as when using Link’s route
attribute it does not reload the page.
Ideal example usage:
const routes = module.exports = require('next-routes')();
const guard = function(route) {
// Check JWT tokens
// ...etc
return true;
}
// Singular guards
routes.add('/', 'index').guard(guard);
// Multiple guards
routes.add('/', 'index').guard([guard, guard]);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:7 (1 by maintainers)
Top Results From Across the Web
[Feature Request] Object based route guards #44 - GitHub
This works just fine for allowing a single object to declare the route guards and the redirect, however it still falls short as...
Read more >How To Use Angular Route Guards As Feature Toggles
They enable the developer to carry out some logic when a user requests a route, and then allow or deny the user access...
Read more >Route Guards in React - JavaScript in Plain English
Route Guard is a mechanism to have more control over the routes that are available throughout your app. These can be simple menu...
Read more >Angular Authentication: Using Route Guards | by Ryan Chenkie
Angular's route guards are interfaces which can tell the router whether or not it should allow navigation to a requested route.
Read more >Common Routing Tasks - Angular
The last route with the path of ** is a wildcard route. The router selects this route if the requested URL doesn't match...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think getInitialProps is the best place to do this to have it work on both server and client routing
I closed it as I used
getInitialProps
as suggested by @fridays. While I still would like to see this feature added, I’ll probably end up doing it in my own fork as this repository doesn’t seem to be very active.