Storybook — configure with NextRouter

Fred Wong
fredwong-it
Published in
May 31, 2023

I got this error message in storybook today.

Since I redesigned the code to use the router.push , it used useRouter , and storybook could not pick it up properly.

Solution

.storybook/main.js

  • add storybook-addon-next-router under addons (npm install first)

.storybook/preview.js

  • add nextRouter config in here

Then it works!

--

--