{"record":{"id":"2074ea1b07c7534e","repo":"framework7io/framework7","slug":"framework7-route-with-name-name-not-found","errorCode":null,"errorMessage":"Framework7: route with name \"${name}\" not found","messagePattern":"Framework7: route with name \"(.+?)\" not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/modules/router/router-class.js","lineNumber":321,"sourceCode":"      url,\n      path,\n    };\n  }\n\n  generateUrl(parameters = {}) {\n    if (typeof parameters === 'string') {\n      return parameters;\n    }\n    const { name, path, params, query } = parameters;\n    if (!name && !path) {\n      throw new Error('Framework7: \"name\" or \"path\" parameter is required');\n    }\n    const router = this;\n    const route = name ? router.findRouteByKey('name', name) : router.findRouteByKey('path', path);\n\n    if (!route) {\n      if (name) {\n        throw new Error(`Framework7: route with name \"${name}\" not found`);\n      } else {\n        throw new Error(`Framework7: route with path \"${path}\" not found`);\n      }\n    }\n    const url = router.constructRouteUrl(route, { params, query });\n\n    if (url === '') {\n      return '/';\n    }\n\n    if (!url) {\n      throw new Error(`Framework7: can't construct URL for route with name \"${name}\"`);\n    }\n    return url;\n  }\n\n  // eslint-disable-next-line\n  constructRouteUrl(route, { params, query } = {}) {","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/framework7io/framework7/blob/655759126686766530a027b2f8f369c991d63d1c/src/core/modules/router/router-class.js#L303-L339","documentation":"This error is thrown by Router.generateUrl when the caller passes a parameters object with a `name` property but the router cannot find any registered route whose `name` matches it (findRouteByKey('name', name) returns undefined). It means the named-route lookup failed — the route either was never defined in the routes configuration, belongs to a different router/view, or the name string is misspelled. It fires only when `name` is provided (a missing path produces a different error earlier); fix it by correcting the name or adding a route entry with that name to the router's routes array, or wrap generateUrl in try-catch if dynamic route names are expected.","triggerScenarios":"`router.generateUrl({ name: 'aboutPage' })` where no route was defined with `name: 'aboutPage'` (typo, missing route module, or route defined in a different View's router).","commonSituations":"Renamed routes without updating generateUrl/navigate calls; routes registered on another view's router; case-sensitive name mismatches.","solutions":["Add a `name` to the target route definition and make it match exactly","Fix the name string in the generateUrl call","Ensure the route exists in this router's routes (or master detail / child routes tables)","Call generateUrl on the View's router that actually holds the route"],"exampleFix":"// before\nrouter.generateUrl({ name: 'aboutPage' });\n\n// after\nroutes = [{ path: '/about/', name: 'aboutPage', component: AboutPage }];\nrouter.generateUrl({ name: 'aboutPage' });","handlingStrategy":"validation","validationCode":"const known = (router.routes || []).flatMap(r => r.routes || r).filter(r => r.name);\nif (!known.some(r => r.name === name)) {\n  throw new Error(`Route name \"${name}\" is not defined`);\n}","typeGuard":"function routeNameExists(router, name) {\n  const flat = (router.routes || []).flatMap(r => (r.routes ? r.routes : [r]));\n  return flat.some(r => r && r.name === name);\n}","tryCatchPattern":"try {\n  const url = router.generateUrl({ name });\n} catch (e) {\n  if (/route with name .* not found/.test(e.message)) {\n    console.error(`Add or fix a route named \"${name}\"`);\n  } else throw e;\n}","preventionTips":["Give every navigable route a unique name","Centralize route names in constants and import them","Verify the route is registered on the router you call","Add a startup check that all referenced names exist"],"tags":["router","routes","url-generation","framework7"],"backgroundTag":"route-not-found","analyzedSha":"655759126686766530a027b2f8f369c991d63d1c","analyzedAt":"2026-09-02T19:48:40.711Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}