When you're using usePathname from NextJS
import { usePathname } from 'next/navigation' const pathname = usePathname() And want to change the pathname for Storybook purposes, update your story as follows:
export const Default = { parameters: { nextjs: { appDirectory: true, navigation: { pathname: '/games' } } }, args: { ... } }; Source: qcatch on Feb 22, 2024
https://github.com/storybookjs/storybook/discussions/25470
Top comments (1)
Also possible to fix on system-wide level by adding similar config to
preview.tsx(preview.tsorpreview.js, whenever was used on your project):With this way this default args will be applied to all stories you have.