Skip to content

Is It Okay to Have Multiple beforeEach Guards ? #2424

Discussion options

You must be logged in to vote

Is it okay to have multiple beforeEach guards? Does Vue Router handle these sequentially without any performance or logical issues?

From the docs:

Global before guards are called in creation order, whenever a navigation is triggered.

https://router.vuejs.org/guide/advanced/navigation-guards.html#Global-Before-Guards

Are there better patterns to ensure the guard is only active in production without duplicating unnecessary logic in development?

I'm not sure I understand what you mean by "without duplicating unnecessary logic in development"? You mean using another approach than the if (import.meta.env.PROD) condition?

To my knowledge this is the most standard approach for this, and th…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@posva
Comment options

@loic-bellinger
Comment options

Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants