Skip to main content

Index Routes

Index routes render in their parent’s <Outlet /> when the parent’s path exactly matches the URL. They provide default content for layout routes and are commonly used for home pages, dashboards, and list views.

Basic Index Routes

Use the index() helper to define an index route:
This renders home.tsx at the root path /.

Index Routes in Nested Layouts

Index routes are most useful as default children of parent routes:
URL behavior:
  • /dashboard → renders dashboard.tsx with overview.tsx in the outlet (index route)
  • /dashboard/analytics → renders dashboard.tsx with analytics.tsx in the outlet
  • /dashboard/settings → renders dashboard.tsx with settings.tsx in the outlet

Parent Route with Index

File-Based Index Routes

When using flatRoutes(), use _index for index routes:
Alternatively, use folder-based structure:

Index vs. Layout Routes

Understand the difference between index routes and layout routes: Layout route (no path, wraps children):
Index route (default child):

Loading Data in Index Routes

Index routes can have loaders like any other route:

Index Route Actions

Handle form submissions in index routes:
Link to index routes using the parent’s path:
Index routes require special handling for active link styling:
Without end, the link to . (index) would always be active since all child paths start with /dashboard.

Multiple Index Routes (Layouts)

Different layout routes can have their own index routes:

Index Route Redirects

Redirect from an index route:

Error Boundaries

Index routes can have their own error boundaries:

Index Route Meta

Export meta data for SEO:

Common Patterns

Dashboard with Overview

Product Listing

Documentation Site

Best Practices

  1. Default content: Use index routes for the most common/default child view
  2. Use end prop: Add end to NavLinks pointing to index routes
  3. Descriptive names: Name index route files after their content (e.g., overview.tsx not index.tsx)
  4. Avoid empty outlets: Always provide an index route for layouts with children
  5. Consider redirects: Redirect from index routes when user state requires it
  6. Data loading: Don’t hesitate to add loaders to index routes