Skip to main content
navigateTo is available on both server side and client side. It can be used within the Nuxt context, or directly, to perform page navigation.
Make sure to always use await or return on result of navigateTo when calling it.
navigateTo cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use sendRedirect instead.

Type Signature

Parameters

RouteLocationRaw | undefined | null
default:"'/'"
The route to navigate to. Can be a plain string or a route object. When passed as undefined or null, it will default to '/'.
NavigateToOptions
Navigation options object.

Examples

Within a Vue Component

Within Route Middleware

When using navigateTo within route middleware, you must return its result to ensure the middleware execution flow works correctly.The following implementation will not work as expected:
In this case, navigateTo will be executed but not returned, which may lead to unexpected behavior.
The external parameter influences how navigating to URLs is handled:
  • Without external: true:
    • Internal URLs navigate as expected.
    • External URLs throw an error.
  • With external: true:
    • Internal URLs navigate with a full-page reload.
    • External URLs navigate as expected.

Opening a Page in a New Tab

See Also