vuejs/vue-router · warning
relative params navigation requires a current route.
Error message
relative params navigation requires a current route.
What it means
This is a development-mode warning emitted by normalizeLocation when a location object specifies params (e.g. { params: { id: 1 } }) without a name or explicit path, but no current route is matched. Relative params navigation requires an existing matched route to resolve the params against (either the current route's name/path or its matched record path). Without it, the params cannot be applied and the navigation falls through to path resolution.
Source
Thrown at src/util/location.js:41
if (params && typeof params === 'object') {
next.params = extend({}, params)
}
return next
}
// relative params
if (!next.path && next.params && current) {
next = extend({}, next)
next._normalized = true
const params: any = extend(extend({}, current.params), next.params)
if (current.name) {
next.name = current.name
next.params = params
} else if (current.matched.length) {
const rawPath = current.matched[current.matched.length - 1].path
next.path = fillParams(rawPath, params, `path ${current.path}`)
} else if (process.env.NODE_ENV !== 'production') {
warn(false, `relative params navigation requires a current route.`)
}
return next
}
const parsedPath = parsePath(next.path || '')
const basePath = (current && current.path) || '/'
const path = parsedPath.path
? resolvePath(parsedPath.path, basePath, append || next.append)
: basePath
const query = resolveQuery(
parsedPath.query,
next.query,
router && router.options.parseQuery
)
let hash = next.hash || parsedPath.hash
if (hash && hash.charAt(0) !== '#') {View on GitHub (pinned to 680ccc68c5)
Solutions
- Add a route `name` to the location object so params resolve to the named route: router.push({ name: 'user', params: { id: 1 } }).
- Provide an explicit `path` instead of relative params: router.push({ path: `/user/${id}` }).
- Ensure a current route exists before doing relative navigation (await router.isReady() in Vue Router 3.5+ / check this.$route.matched.length).
- If using a catch-all route (path: '*'), remember it counts as a matched route; if matched.length is 0, you cannot use relative params at all.
Example fix
// before
router.push({ params: { id: userId } })
// after
router.push({ name: 'user', params: { id: userId } }) Defensive patterns
Strategy: validation
Validate before calling
function canPushRelativeParams (router, params) {
const current = router.currentRoute
return Boolean(
current &&
(current.name || current.matched.length) &&
params && Object.keys(params).length > 0
)
} Type guard
function hasCurrentRoute (r) {
return Boolean(r.currentRoute && (r.currentRoute.name || r.currentRoute.matched.length > 0))
} Prevention
- Always include a `name` (or full `path`) when passing `params` to push/replace.
- Never rely on relative params at initial navigation; await router.isReady() first.
- Add a lint/test rule that locations using `params` also specify `name` or `path`.
When it happens
Trigger: Calling router.push({ params: {...} }) (or router.replace/resolve) with no `name` and no `path` in the location while currentRoute.matched is empty — i.e. no current route (e.g. at initial load before any navigation, or when the current URL matched no route).
Common situations: Redirect guards running on first app load before the initial route is resolved; calling push with only params inside a catch-all/no-match route; code that assumes a default route is active when the user landed on an unmatched URL; forgetting the `name` property in a location object that uses params.
Related errors
- missing param for ${routeMsg}: ${e.message}
- props in "${route.path}" is a ${typeof config}, expecting an
- Duplicate param keys in route with path: "${path}"
- [vue-router]: Missing current instance. ${method}() must be
- [vue-router] ${message}
AI-assisted analysis of vuejs/vue-router@680ccc68c5 (2026-09-02).
Data as JSON: /api/errors/341d06357254c7fe.
Report an issue: GitHub.