framework7io/framework7 · error · Error

Framework7: route with path "${path}" not found

Error message

Framework7: route with path "${path}" not found

What it means

`generateUrl({ path })` searches all route tables for a route whose `path` matches. When none matches, it throws `route with path "..." not found`. This is the name-less branch of the same lookup that produces the "name not found" error.

Source

Thrown at src/core/modules/router/router-class.js:323

    };
  }

  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) {
      throw new Error(`Framework7: can't construct URL for route with name "${name}"`);
    }
    return url;
  }

  // eslint-disable-next-line
  constructRouteUrl(route, { params, query } = {}) {
    const { path } = route;
    const toUrl = compile(path);

View on GitHub (pinned to 6557591266)

Solutions

  1. Match the path exactly as defined in the routes array (watch trailing slashes and case)
  2. Use a route `name` instead of a raw path for safer lookups
  3. Register the missing route if it was intended
  4. Verify which router holds the route and call generateUrl on that router

Example fix

// before
router.generateUrl({ path: '/About' }); // route defined as '/about/'

// after
router.generateUrl({ path: '/about/' });
Defensive patterns

Strategy: validation

Validate before calling

function pathExists(router, path) {
  const flat = (router.routes || []).flatMap(r => (r.routes ? r.routes : [r]));
  return flat.some(r => r && r.path === path);
}
if (!pathExists(router, path)) console.warn(`Path ${path} not registered`);

Type guard

function routePathExists(router, path) {
  const flat = (router.routes || []).flatMap(r => (r.routes ? r.routes : [r]));
  return flat.some(r => r && r.path === path);
}

Try / catch

try {
  const url = router.generateUrl({ path });
} catch (e) {
  if (/route with path .* not found/.test(e.message)) {
    console.error(`No route matches path "${path}"; check exact spelling/trailing slash`);
  } else throw e;
}

Prevention

When it happens

Trigger: `router.generateUrl({ path: '/some/url/' })` where the path is not among the router's registered route paths (typo, missing trailing slash difference, or route living in another router).

Common situations: Path casing or trailing-slash mismatches; dynamic routes defined with different patterns; calling generateUrl on the wrong View's router.

Related errors


AI-assisted analysis of framework7io/framework7@6557591266 (2026-09-02). Data as JSON: /api/errors/35a8f4520a4acb29. Report an issue: GitHub.