-
When a user navigates to a page, I need to check their permissions and render the page accordingly based on those permissions. How can I achieve this with a global router guard? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There's a ton of ways to do this, and it doesn't necessarily have to be a global navigation guard. For example, you could keep track of the user and their permissions in a global store and render the page based on the state of that store. From what I can tell, navigation guards are more meant to redirect a user to a different page. Alternatively, you alter store state from a navigation guard: https://router.vuejs.org/guide/advanced/navigation-guards.html#Global-injections-within-guards |
Beta Was this translation helpful? Give feedback.
-
You can attach guards with |
Beta Was this translation helpful? Give feedback.
You can attach guards with
router.beforeEach()
and other guards like usual, after creating your router instance.