framework7io/framework7 · error · Error

Framework7: it is not allowed to use router methods on globa

Error message

Framework7: it is not allowed to use router methods on global app router. Use router methods only on related View, e.g. app.views.main.router.${method}(...)

What it means

The app-level router exists but is not attached to any View, so navigation methods have no target container. Framework7 throws when a router method (navigate, back, etc.) is invoked on it, and the thrown message tells you to use a View's router instead.

Source

Thrown at src/core/modules/router/app-router-check.js:3

export default function appRouterCheck(router, method) {
  if (!router.view) {
    throw new Error(
      `Framework7: it is not allowed to use router methods on global app router. Use router methods only on related View, e.g. app.views.main.router.${method}(...)`,
    );
  }
}

View on GitHub (pinned to 6557591266)

Solutions

  1. Call the method on a View's router, e.g. `app.views.main.router.navigate('/page/')`
  2. Pass the view router into helpers instead of the app instance
  3. If you have multiple views, pick the correct one: app.views[name].router

Example fix

// before
app.router.navigate('/about/');

// after
app.views.main.router.navigate('/about/');
Defensive patterns

Strategy: type-guard

Validate before calling

function assertViewRouter(router, method) {
  if (!router || !router.view) {
    throw new Error(`Use a View router (e.g. app.views.main.router.${method}()), not app.router`);
  }
}

Type guard

function isViewRouter(router) {
  return !!router && 'view' in router && !!router.view;
}

Try / catch

try {
  app.views.main.router.navigate('/about/');
} catch (e) {
  if (/global app router/.test(e.message)) {
    console.error('Call router methods on a View router, e.g. app.views.main.router');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `app.router.navigate('/page/')`, `app.router.back()`, `app.router.refreshPage()` etc. directly on the global app router instead of `app.views.main.router`.

Common situations: Copy-pasted code using `app.router` from tutorials; helper functions receiving the app instead of the view router; refactors that dropped the `.views.main` segment.

Related errors


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