title: VueJS pass parameters through the router next()
body: <p>I want to pass the last route into my router when I'm in /login to redirect the user when is logged to desired route.</p>
  
  <p>So the user go to <code>/payment</code> I redirect to <code>/login</code> and when the authentication is ok I want to redirect the user to <code>payement</code></p>
  
  <p>Here is my router.js :</p>
  
  <pre><code>import ...
  
  Vue.use(Router)
  
  let router = new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [
      {
        path: '/',
        name: 'home',
        component: Home
      },
      {
        path: '/login',
        name: 'login',
        component: Login
      },
      {
        path: '/about',
        name: 'about',
        component: About
      },
      {
        path: '/payment',
        name: 'payment',
        component: Payment,
        meta: {
          requiresAuth: true
        }
      },
      {
        path: '/my-account',
        name: 'my-account',
        component: MyAccount,
        meta: {
          requiresAuth: true
        }
      }
    ]
  })
  
  router.beforeEach((to, from, next) =&gt; {
    console.log('Before Each Routes')
    if(to.matched.some(record =&gt; record.meta.requiresAuth)) {
      if (store.getters.isLoggedIn) {
        console.log('Logged in')
        next()
        return
      }
      console.log(to.fullPath)
      next({
        path: '/login',
        params: { nextUrl: to.fullPath }
      })
      return
    } else {
      console.log(to.fullPath)
      next()
    }
  })
  
  export default router
  </code></pre>
  
  <p>So I set some console.log and I got this :</p>
  
  <p>if I go directly to /login, Output :</p>
  
  <pre><code>Before Each Routes
  /login
  </code></pre>
  
  <p>Then if I go to /payment, Output :</p>
  
  <pre><code>Before Each Routes
  /payment
  Before Each Routes
  /login
  </code></pre>
  
  <p>So now when I go in my login component and I use <code>this.$route.params.nextUrl</code> it's undefined. The <code>next()</code> parameter doesn't exist and I don't know why.</p>
  
  <p>What I'm doing wrong ?</p>