GoRouter.dev

Current field guide · 2026

Make the URL carry the right state

Read required identifiers from pathParameters and optional filters from state.uri.queryParameters.

Try the same destination in the Route Atlas and write down which values identify the resource and which merely change its view. Continue with redirection when a guard changes the route; keep the original intended destination in your explanation.

Edition published 21 Oct 2026go_router 18.1.1 reference
On this page

Paths identify resources

For /books/:bookId, the actual URI /books/42 supplies bookId = 42. Receiving a string does not establish that a record exists. Validate the identifier and handle a missing or inaccessible resource in your application.

Queries refine a destination

A URI such as /books?sort=recent&page=2 can represent a list with shareable filters. Parse numbers safely and choose explicit defaults when values are absent or malformed. URI constructors handle encoding more reliably than manual string concatenation.

Keep extra optional

extra can carry an object during navigation, but someone who opens a copied URL may not have that object. The router supports an extra codec for serialization requirements; that still calls for a deliberate design and does not justify putting secrets in browser history.

Choose one source of truth

If both the URL and a controller own the same filter, specify which one wins on Back, Forward, and reload. Rebuild from the URI when a link changes the destination. Never place passwords, tokens, or sensitive personal information in path or query parameters.

dart / example
final bookId = state.pathParameters['bookId'];
final sort = state.uri.queryParameters['sort'] ?? 'title';
final page = int.tryParse(
  state.uri.queryParameters['page'] ?? '',
) ?? 1;

final destination = Uri(
  path: '/books',
  queryParameters: {'sort': 'recent', 'page': '2'},
);
context.go(destination.toString());
Earlier edition: read the complete original guide. Its older APIs are kept in historical context.

Sources & version context

GoRouter.dev documentation edition. Examples illustrate the APIs described in the linked primary documentation. Adapt application-owned widgets and services to your project. They are not an executed Flutter session in this browser.

Find your next route