Storybook Addon for Remix React Router

6.1.0 · active · verified Sun Apr 19

This Storybook addon integrates Remix React Router into your stories, enabling comprehensive testing and demonstration of components that rely on React Router's navigation and state management. The current stable version is 6.1.0, released recently in March 2026, indicating an active development and maintenance cadence with frequent updates to support new Storybook and React Router versions. A key differentiator is its explicit support for `react-router@7` and newer, making a clear distinction from earlier versions (v3 and below) that supported `react-router-dom`. It provides a `withRouter` decorator and `reactRouterParameters` to configure routes, locations, path parameters, search parameters, and state directly within your stories, allowing for precise control over the routing context for each component variant. This addon ensures that components designed for a Remix React Router environment can be faithfully rendered and interacted with in isolation within Storybook.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to configure and use the `withRouter` decorator and `reactRouterParameters` to set up routing context for a `UserProfile` component in Storybook, including path parameters and search parameters for different story states.

import { withRouter, reactRouterParameters } from 'storybook-addon-remix-react-router';
import type { Meta, StoryObj } from '@storybook/react';
import { Outlet, Link } from 'react-router-dom'; // Example component using router hooks

const UserProfile = () => (
  <div>
    <h1>User Profile Page</h1>
    <p>Viewing profile for user ID: <Outlet /></p>
    <nav>
      <Link to="/users/42">Profile</Link> | <Link to="/users/42?tab=activityLog">Activity Log</Link>
    </nav>
  </div>
);

const meta: Meta<typeof UserProfile> = {
  title: 'User Profile',
  component: UserProfile,
  decorators: [withRouter],
  parameters: {
    reactRouter: reactRouterParameters({
      location: {
        pathParams: { userId: '42' },
        searchParams: { tab: 'profile' },
        state: { fromPage: 'homePage' }
      },
      routing: { path: '/users/:userId' },
    }),
  },
};

export default meta;

type Story = StoryObj<typeof UserProfile>;

export const Default: Story = {};

export const ActivityLogTab: Story = {
  parameters: {
    reactRouter: reactRouterParameters({
      location: {
        pathParams: { userId: '42' },
        searchParams: { tab: 'activityLog' }
      },
      routing: { path: '/users/:userId' }
    })
  }
};

view raw JSON →