Skip to content

[Bug]: Next.js Catch-All path segments are basically unusable on sb@v10 #32971

@FezVrasta

Description

@FezVrasta

Describe the bug

Support for Catch-All segments was undocumented and worked this way:

{
  nextjs: {
    appDirectory: true,
    navigation: {
      segments: [
        ['catch-all', 'as/many/as/you/want', 'c']
      ]
    }
  }
}

The trailing c marked it as "catch-all".

This was removed on storybook v10, now it expects this:

{
  nextjs: {
    appDirectory: true,
    navigation: {
      segments: [
        ['catch-all', ['as', 'many', 'as', 'you', 'want']]
      ]
    }
  }
}

This works fine for useParams, but errors with useSelectedLayoutSegment. It errors with:

Image

The only workaround I found is the following, but I think it's about time to properly document this functionality and fix it if you ask me.

export function makeMockSegment(path: string[]): string[] {
  Object.defineProperty(path, "startsWith", {
    value: () => {
      return false;
    },
  });
  return path;
}


[...]

nextjs: {
  appDirectory: true,
  navigation: {
    segments: [
      ['catch-all', makeMockSegment(['as', 'many', 'as', 'you', 'want'])]
    ]
  }
}

Reproduction link

https://stackblitz.com/edit/github-vm266l82?file=src%2Fstories%2FPage.tsx

Reproduction steps

No response

System

System:
    OS: macOS 26.0
    CPU: (10) arm64 Apple M1 Max
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.9.0 - ~/.local/share/mise/installs/node/24.9.0/bin/node
    Yarn: 4.6.0 - ~/.local/share/mise/installs/yarn/4.6.0/bin/yarn <----- active
    npm: 11.6.0 - ~/.local/share/mise/installs/node/24.9.0/bin/npm
  Browsers:
    Chrome: 142.0.7444.60
    Safari: 26.0
  npmPackages:
    @storybook/addon-links: 10.0.5 => 10.0.5 
    @storybook/nextjs: 10.0.5 => 10.0.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions