npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

storybook-addon-tanstack-router

v0.1.0

Published

Storybook decorator and parameter helpers for TanStack Router — provides router context, route params, search params, and loader data in stories

Readme

storybook-addon-tanstack-router

Storybook addon that provides TanStack Router context for your stories. Configure route params, search params, and loader data declaratively.

Install

pnpm add -D storybook-addon-tanstack-router

Quick Start

Global decorator (recommended)

// .storybook/preview.ts
import { withTanStackRouter } from "storybook-addon-tanstack-router";

export const decorators = [withTanStackRouter];

Or register as an addon to auto-apply:

// .storybook/main.ts
export default {
  addons: ["storybook-addon-tanstack-router"],
};

Per-story configuration

import type { Meta, StoryObj } from "@storybook/react";
import { tanstackRouterParameters } from "storybook-addon-tanstack-router";
import { UserProfile } from "./UserProfile";

const meta: Meta<typeof UserProfile> = {
  component: UserProfile,
};
export default meta;

type Story = StoryObj<typeof UserProfile>;

export const Default: Story = {
  parameters: {
    tanstackRouter: tanstackRouterParameters({
      location: {
        path: "/users/$userId",
        params: { userId: "42" },
        search: { tab: "settings" },
      },
      loader: {
        data: { user: { id: "42", name: "Alice" } },
      },
    }),
  },
};

API

withTanStackRouter

A Storybook decorator that wraps stories with RouterProvider and a memory-based router. Apply globally or per-story.

tanstackRouterParameters(config)

Type-safe helper for configuring the addon. Returns the config as-is — it exists purely for TypeScript autocompletion.

config.location

| Property | Type | Description | | -------- | ------------------------- | ------------------------------------------- | | path | string | Route path pattern, e.g. '/users/$userId' | | params | Record<string, string> | Route params to substitute into the path | | search | Record<string, unknown> | Search/query params | | hash | string | URL hash fragment |

config.loader

| Property | Type | Description | | -------- | --------- | ------------------------------------------ | | data | unknown | Static data returned by the route's loader |

How It Works

The addon creates a minimal TanStack Router setup for each story:

  1. Builds a route tree with createRootRoute + createRoute
  2. Creates a createMemoryHistory with the configured location
  3. Wraps the story in RouterProvider

This means your components can use all TanStack Router hooks (useParams, useSearch, useLoaderData, useNavigate, etc.) without any manual setup.

TanStack Start

This addon handles the Router side. If you're using TanStack Start (the full-stack framework), you also need to mock server-side code (server functions, SSR, Cloudflare workers) at the Vite config level. See the storybook-play-testing skill for a complete TanStack Start + Storybook setup guide.

License

MIT