framework7io/framework7 · error · Error
Framework7: "name" or "path" parameter is required
Error message
Framework7: "name" or "path" parameter is required
What it means
`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.
Source
Thrown at src/core/modules/router/router-class.js:314
const hash = url.split('#')[1];
const params = {};
const path = url.split('#')[0].split('?')[0];
return {
query,
hash,
params,
url,
path,
};
}
generateUrl(parameters = {}) {
if (typeof parameters === 'string') {
return parameters;
}
const { name, path, params, query } = parameters;
if (!name && !path) {
throw new Error('Framework7: "name" or "path" parameter is required');
}
const router = this;
const route = name ? router.findRouteByKey('name', name) : router.findRouteByKey('path', path);
if (!route) {
if (name) {
throw new Error(`Framework7: route with name "${name}" not found`);
} else {
throw new Error(`Framework7: route with path "${path}" not found`);
}
}
const url = router.constructRouteUrl(route, { params, query });
if (url === '') {
return '/';
}
if (!url) {View on GitHub (pinned to 6557591266)
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
Example fix
// before
router.generateUrl({ params: { id: 5 } });
// after
router.generateUrl({ name: 'item', params: { id: 5 } }); Defensive patterns
Strategy: validation
Validate before calling
function safeGenerateUrl(router, parameters) {
if (typeof parameters === 'string') return router.generateUrl(parameters);
if (!parameters || (!parameters.name && !parameters.path)) {
throw new Error('generateUrl needs name or path');
}
return router.generateUrl(parameters);
} Type guard
function hasNameOrPath(p) {
return !!p && (typeof p.name === 'string' || typeof p.path === 'string');
} Try / catch
try {
const url = router.generateUrl(parameters);
} catch (e) {
if (/"name" or "path" parameter is required/.test(e.message)) {
console.error('Pass { name } or { path } to generateUrl');
} else throw e;
} Prevention
- 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
When it happens
Trigger: Calling `router.generateUrl({ params: {...} })` or `router.generateUrl({ query: 'a=1' })` — an object without the required `name` or `path` key.
Common situations: Building URLs dynamically where the name/path variable is undefined due to an earlier failure; destructuring mistakes; passing an empty object.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Framework7: can't construct URL for route with name "${name}
- Framework7: route with name "${name}" not found
- Framework7: route with path "${path}" not found
- Framework7: error constructing route URL from passed params:
- Framework7: it is not allowed to use router methods on globa
AI-assisted analysis of framework7io/framework7@6557591266 (2026-09-02).
Data as JSON: /api/errors/5f18782a87c43d54.
Report an issue: GitHub.