Skip to main content

Overview

Routing drives your application’s user interface based on URLs. In client-rendered Meteor apps, routing happens on the client side, allowing for instant navigation without server round-trips while maintaining browser features like bookmarking, back/forward buttons, and sharing links.

Why Client-Side Routing?

Unlike traditional server-rendered apps where each URL change triggers a server request, Meteor apps:
  • Load once and update the UI based on URL changes
  • Navigate instantly without page reloads
  • Maintain state across navigation
  • Still support all browser URL features
The URL represents linkable state - the parts of your application that users should be able to bookmark, share, or navigate to directly.

Flow Router

The recommended routing package for Meteor is Flow Router Extra:
Flow Router Extra extends the original Flow Router with additional features like waitOn for handling subscriptions and built-in template context.

Defining Routes

Basic Route

Route with Parameters

URL Pattern Matching

Rendering Templates with Blaze

Using Blaze Layout

Install the Blaze Layout package:

Define a Layout Template

Render Templates on Route Changes

Page Components

Page components are top-level templates that:
  1. Collect route information
  2. Subscribe to data
  3. Fetch data from collections
  4. Pass data to child components

Accessing Route Information

Current Route

Reactive Route Helpers

Programmatic Navigation

Generate URLs

Active Route Highlighting

Or using ActiveRoute (built into Flow Router Extra):

Route Groups

Organize routes with common properties:

Route Triggers

Execute code when entering or exiting routes:

Not Found (404) Routes

Using with React

Query Parameters

Reading Query Params

Setting Query Params

Best Practices

Keep URLs Linkable

Only put state in the URL that users should be able to bookmark or share.

Subscribe in Page Components

Use Named Routes