How to protect your routes using beforeEnter in Vue Js, allowing only logged in user to navigate to it.

In Angular, you have canActivate for check for login and roles before you enter a route, in Vue Js you have beforeEnter

this is your main file in Vue Js.

You authGuard.ts can be like this

That is pretty much it.

Leave a comment