{"record":{"id":"5f18782a87c43d54","repo":"framework7io/framework7","slug":"framework7-name-or-path-parameter-is-required","errorCode":null,"errorMessage":"Framework7: \"name\" or \"path\" parameter is required","messagePattern":"Framework7: \"name\" or \"path\" parameter is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/modules/router/router-class.js","lineNumber":314,"sourceCode":"    const hash = url.split('#')[1];\n    const params = {};\n    const path = url.split('#')[0].split('?')[0];\n    return {\n      query,\n      hash,\n      params,\n      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) {","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/framework7io/framework7/blob/655759126686766530a027b2f8f369c991d63d1c/src/core/modules/router/router-class.js#L296-L332","documentation":"`router.generateUrl(parameters)` builds a URL from a route either by `name` or by `path`. If the parameters object (after string shortcut handling) contains neither a `name` nor a `path`, Framework7 cannot resolve any route and throws.","triggerScenarios":"Calling `router.generateUrl({ params: {...} })` or `router.generateUrl({ query: 'a=1' })` — an object without the required `name` or `path` key.","commonSituations":"Building URLs dynamically where the name/path variable is undefined due to an earlier failure; destructuring mistakes; passing an empty object.","solutions":["Pass the route name: `router.generateUrl({ name: 'about' })`","Or pass the path: `router.generateUrl({ path: '/about/' })`","Or simply pass the URL string directly: `router.generateUrl('/about/')`","Check why the name/path variable is undefined upstream"],"exampleFix":"// before\nrouter.generateUrl({ params: { id: 5 } });\n\n// after\nrouter.generateUrl({ name: 'item', params: { id: 5 } });","handlingStrategy":"validation","validationCode":"function safeGenerateUrl(router, parameters) {\n  if (typeof parameters === 'string') return router.generateUrl(parameters);\n  if (!parameters || (!parameters.name && !parameters.path)) {\n    throw new Error('generateUrl needs name or path');\n  }\n  return router.generateUrl(parameters);\n}","typeGuard":"function hasNameOrPath(p) {\n  return !!p && (typeof p.name === 'string' || typeof p.path === 'string');\n}","tryCatchPattern":"try {\n  const url = router.generateUrl(parameters);\n} catch (e) {\n  if (/\"name\" or \"path\" parameter is required/.test(e.message)) {\n    console.error('Pass { name } or { path } to generateUrl');\n  } else throw e;\n}","preventionTips":["Always include name or path in generateUrl params","Use the string shortcut for plain URLs","Check upstream variables for undefined before calling","Wrap generateUrl in a helper that validates input"],"tags":["router","url-generation","parameters","framework7"],"backgroundTag":"missing-required-argument","analyzedSha":"655759126686766530a027b2f8f369c991d63d1c","analyzedAt":"2026-09-02T19:48:40.711Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}