Adding meta data to routes

I’m trying to add some meta data to individual routes so I can check that data in a universal router guard. In VueJS I used to just add meta: { requiresAuth:true } to a route and then in my router guard I’d check using record.meta.requiresAuth and if that was true I’d then check if the user is authenticated or not. I can’t seem to find the same functionality in F7.

Basically I’m trying to set up routes from login, register, forgot password etc. that don’t need auth and then default all other routes to need auth.

Any ideas?

maybe you can use beforeEnter

routes = [
  {
    path: '/profile/',
    url: 'profile.html',
    // check if the user is logged in
    beforeEnter: checkAuth,
  },
  {
    path: '/profile-edit/',
    url: 'profile-edit.html',
    // check if the user is logged in and has required permission
    beforeEnter: [checkAuth, checkPermission],
  }
]

https://framework7.io/docs/routes.html#route-before-enter-leave

1 Like