npm nuxt 0.3.6
v0.3.6

latest releases: 3.11.2, 3.11.1, 3.11.0...
7 years ago

Features

  • Add redirected key in the result of nuxt.renderRoute(route, context = {}), useful for unit tests
  • Add redirect field in the contextreceived in data (context) and fetch (context), useful for authenticated routes:
// Ex: dashboard.vue
<script>
export default {
  fetch ({ redirect, route }) {
    // Check if user is connected via req.session or JWT...
    redirect({
      path: '/login',
      query: { redirect: route.fullPath }
    })
  }
}
</script>

You can also use redirect('/login') if you don't want to add any query parameter.

The redirect also works for nuxt generate and will create a html page with:

<meta http-equiv="refresh" content="0; url={{ redirectedPath }}" />
<script type="text/javascript">
    window.location.href = '{{ redirectedPath }}'
</script>

Don't miss a new nuxt release

NewReleases is sending notifications on new releases.