# Adding navigation guards to router in Vue2 Quickstart

**URL:** <https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143>\
**Category:** Get Help\
**Created:** [June 6, 2018, 3:31pm UTC](https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143 "2018-06-06T15:31:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![expomas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/expomas/32/5023_2.png) [@expomas](https://community.auth0.com/u/expomas)\
**Post date:** [June 6, 2018, 3:31pm UTC](https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143/1 "2018-06-06T15:31:40Z")

</div>

I went through the Quickstart SPA for Vue, but there was nothing about how to configure the router to allow/disallow certain routes based on authentication. The topic is covered in an Auth0 blog post:

> **[The Complete Guide to Vue.js User Authentication | Auth0](https://auth0.com/blog/complete-guide-to-vue-user-authentication/)**
>
> Learn how to secure a Vue.js application by implementing user authentication, including user login, logout, and sign-up, along with prote...

but the structure of this app is completely different from the Quickstart, and instead of an AuthService, a function is defined in the router code itself.

Does anyone have an opinion on which approach is better? Is there a way to keep the structure of the Quickstart app and easily add logic to allow/disallow routes?

---

<div class="post-metadata">

**Author:** ![expomas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/expomas/32/5023_2.png) [@expomas](https://community.auth0.com/u/expomas)\
**Post date:** [June 7, 2018, 9:46pm UTC](https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143/2 "2018-06-07T21:46:53Z")

</div>

Seems to have something to do with setting up “Navigation guards” in your VueRouter instance, but adding something like

> beforeEnter: {authenticated: true}

to the router logic in the SPA example doesn’t seem to do anything. Seems really weird that this isn’t included in the Quickstart, since it’s such obvious functionality you’ll need with Auth0…

---

<div class="post-metadata">

**Author:** ![expomas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/expomas/32/5023_2.png) [@expomas](https://community.auth0.com/u/expomas)\
**Post date:** [June 8, 2018, 10:50am UTC](https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143/3 "2018-06-08T10:50:37Z")

</div>

It seems Auth0 isn’t terribly serious about implementing with Vue2, and I notice they’ve discontinued their Slack, and there doesn’t seem to be active support here. Can anyone recommend an alternate way to implement JWT with Vue that’s more intuitive?

---

<div class="post-metadata">

**Author:** ![expomas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/expomas/32/5023_2.png) [@expomas](https://community.auth0.com/u/expomas)\
**Post date:** [June 8, 2018, 4:30pm UTC](https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143/4 "2018-06-08T16:30:59Z")

</div>

One last note: if anyone else is struggling with this, there is an “auth-flow” example given in the vue-router documentation that explains how to do this much more clearly:

> **[vue-router/examples/auth-flow at dev · vuejs/vue-router](https://github.com/vuejs/vue-router/tree/dev/examples/auth-flow)**
>
> dev/examples/auth-flow

It’s not specifically for Auth0, but at least gives the basic concept of how to allow/disallow routes

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 25, 2019, 1:52pm UTC](https://community.auth0.com/t/adding-navigation-guards-to-router-in-vue2-quickstart/12143/5 "2019-07-25T13:52:37Z")

</div>


