GoRouter.dev

Current field guide · 2026

Your first route

Connect a URL to a screen, then prove that the same destination works after a reload.

Edition published 21 Oct 2026go_router 18.1.1 reference
On this page

Start with the URL contract

Write down the URLs your app needs before drawing a navigation stack. A useful first map is /, /books/:bookId, and /settings. Give durable resources a path parameter; put optional filters in the query string.

Install for your SDK

Run flutter pub add go_router in the application directory. Let Pub resolve a release compatible with your SDK. The package API reports go_router 18.1.1 with Dart ^3.12.0 and Flutter >=3.44.0 at this edition's publication. An older Flutter project may need an earlier compatible package version.

Connect the router

Create a stable router instance and pass it to MaterialApp.router(routerConfig: router). Recreating it during every widget build can discard the navigation state you meant to preserve. The starter below uses one top-level instance.

Check the real entry points

Open the home screen, navigate to a book, paste that book URL into a fresh browser tab, and refresh it. A working in-app button does not prove that your web host serves deep links correctly. Keep the downloaded starter as a small reference, then add your own screens incrementally.

dart / example
final router = GoRouter(
  routes: [
    GoRoute(path: '/', builder: (_, __) => const HomeScreen()),
    GoRoute(
      path: '/books/:bookId',
      builder: (_, state) => BookScreen(
        id: state.pathParameters['bookId']!,
      ),
    ),
  ],
);

MaterialApp.router(routerConfig: router);
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