Hey legends,
We've recently adopted a monorepo approach with Turborepo and all of my happy stories now have errors 😢 The long and the short of it is that the nextjs parameter configuration in storybook seems to not be taken into account anymore when it comes to the router/navigation config. Here's a snippet of a pretty vanilla story config and the subsequent error message:
parameters: {
nextjs: {
appDirectory: true,
navigation: {
pathname: "/",
},
},
},
Error:
Uncaught Error: invariant expected app router to be mounted
at useRouter (navigation.js:144:1)
at useAuth (useAuth.ts:20:1)
at SignUp (http://localhost:6007/app-(:6007/not-authenticated)-sign-up-index-stories.iframe.bundle.js:1436:73)
at renderWithHooks (react-dom.development.js:10732:1)
at mountIndeterminateComponent (react-dom.development.js:15770:1)
at beginWork$1 (react-dom.development.js:17354:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:19467:1)
at Object.invokeGuardedCallbackImpl (react-dom.development.js:19516:1)
at invokeGuardedCallback (react-dom.development.js:19591:1)
at beginWork (react-dom.development.js:25733:1)
As a curiousity, I've tried pulling the whole app out of the monorepo and rerunning installs and storybook on it and it works swimmingly, as it did before, which leads me to the conclusion that my config is fine and that the nextjs storybook framework is fine but it's all very unhappy with being in a monorepo for some reason 🤷♂️
Any ideas?
Just to note, I have followed the instructions from turborepo about how to add storybook (nothing crazy here except for the pnpm config) and I'm using the latest version of storybook and the addons (7.5.1)