I understand in the page component I can do something like
if(!isAuthenticated){
router.replace("/login")
}
But if 95% of my routes require a login, what's the best way to DRY this up, so I don't have to put this if
statement on all my pages. I looked into middleware but because that runs on the server-side, I can't access the app state.
I'm new to React and Nextjs. I come from an angular background where this would be solved with a route guard, is there anything like this in Nextjs?