framework7io/framework7 · error · Error

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

Error message

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

What it means

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.

Source

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

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

  // eslint-disable-next-line
  constructRouteUrl(route, { params, query } = {}) {

View on GitHub (pinned to 6557591266)

Solutions

  1. Add a `name` to the target route definition and make it match exactly
  2. Fix the name string in the generateUrl call
  3. Ensure the route exists in this router's routes (or master detail / child routes tables)
  4. Call generateUrl on the View's router that actually holds the route

Example fix

// before
router.generateUrl({ name: 'aboutPage' });

// after
routes = [{ path: '/about/', name: 'aboutPage', component: AboutPage }];
router.generateUrl({ name: 'aboutPage' });
Defensive patterns

Strategy: validation

Validate before calling

const known = (router.routes || []).flatMap(r => r.routes || r).filter(r => r.name);
if (!known.some(r => r.name === name)) {
  throw new Error(`Route name "${name}" is not defined`);
}

Type guard

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

Try / catch

try {
  const url = router.generateUrl({ name });
} catch (e) {
  if (/route with name .* not found/.test(e.message)) {
    console.error(`Add or fix a route named "${name}"`);
  } else throw e;
}

Prevention

When it happens

Trigger: `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).

Common situations: Renamed routes without updating generateUrl/navigate calls; routes registered on another view's router; case-sensitive name mismatches.

Related errors


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