Skip to main content
Custom routes allow you to add entirely new pages to the admin dashboard, complete with sidebar navigation and nested routing.

Overview

Routes in the Medusa admin dashboard are powered by React Router 6. You can create custom routes to:
  • Add new pages for custom functionality
  • Create nested routes under existing sections
  • Add items to the sidebar navigation
  • Build multi-page workflows

Creating a Custom Route

Basic Route

Create a new route by defining a React component and exporting a route configuration:
1

Create Route File

Create a new file in your admin extensions directory:
2

Define the Component

3

Export Route Configuration

The route will be automatically registered and accessible at /analytics.

Route Configuration Options

The defineRouteConfig function accepts the following options:

Route File Structure

The file path determines the route path:

Dynamic Routes

Use [param] syntax for dynamic route segments:

Nested Routes

Nest your custom routes under existing dashboard sections:
Available nested positions (from packages/admin/admin-shared/src/extensions/routes/constants.ts:1):
  • /orders
  • /products
  • /inventory
  • /customers
  • /promotions
  • /price-lists

Data Loading

Use React Router loaders for data fetching:

Using the Admin SDK

Fetch data using the Medusa Admin SDK:

Programmatic Navigation

Use React Router hooks for navigation:

Layouts

Custom Layout

Create a layout for multiple related routes:

Settings Routes

Add custom settings pages:
Settings routes are automatically grouped in the Settings section.

Route Guards

Protect routes with authentication or permissions:

Complete Example

Here’s a complete example with data fetching, forms, and navigation:

Best Practices

Choose route paths that clearly describe the page content (e.g., /reports/sales instead of /r/s).
Always show loading indicators while fetching data to improve user experience.
Use error boundaries and show helpful error messages when data loading fails.
Use TanStack Query for data fetching to get automatic caching, refetching, and optimistic updates.

Next Steps