{"record":{"id":"341d06357254c7fe","repo":"vuejs/vue-router","slug":"relative-params-navigation-requires-a-current-rout","errorCode":null,"errorMessage":"relative params navigation requires a current route.","messagePattern":"relative params navigation requires a current route\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/util/location.js","lineNumber":41,"sourceCode":"    if (params && typeof params === 'object') {\n      next.params = extend({}, params)\n    }\n    return next\n  }\n\n  // relative params\n  if (!next.path && next.params && current) {\n    next = extend({}, next)\n    next._normalized = true\n    const params: any = extend(extend({}, current.params), next.params)\n    if (current.name) {\n      next.name = current.name\n      next.params = params\n    } else if (current.matched.length) {\n      const rawPath = current.matched[current.matched.length - 1].path\n      next.path = fillParams(rawPath, params, `path ${current.path}`)\n    } else if (process.env.NODE_ENV !== 'production') {\n      warn(false, `relative params navigation requires a current route.`)\n    }\n    return next\n  }\n\n  const parsedPath = parsePath(next.path || '')\n  const basePath = (current && current.path) || '/'\n  const path = parsedPath.path\n    ? resolvePath(parsedPath.path, basePath, append || next.append)\n    : basePath\n\n  const query = resolveQuery(\n    parsedPath.query,\n    next.query,\n    router && router.options.parseQuery\n  )\n\n  let hash = next.hash || parsedPath.hash\n  if (hash && hash.charAt(0) !== '#') {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/vuejs/vue-router/blob/680ccc68c506cca9be6207745043245d61fa715a/src/util/location.js#L23-L59","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nrouter.push({ params: { id: userId } })\n// after\nrouter.push({ name: 'user', params: { id: userId } })","handlingStrategy":"validation","validationCode":"function canPushRelativeParams (router, params) {\n  const current = router.currentRoute\n  return Boolean(\n    current &&\n    (current.name || current.matched.length) &&\n    params && Object.keys(params).length > 0\n  )\n}","typeGuard":"function hasCurrentRoute (r) {\n  return Boolean(r.currentRoute && (r.currentRoute.name || r.currentRoute.matched.length > 0))\n}","tryCatchPattern":null,"preventionTips":["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`."],"tags":["vue-router","navigation","params","relative-navigation"],"backgroundTag":"relative-params-navigation-without-current-route","analyzedSha":"680ccc68c506cca9be6207745043245d61fa715a","analyzedAt":"2026-09-02T19:19:01.204Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}