-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Using Storybook with Next@15 RC fails at header mocks #29380
Comments
Also trying Next.js 15 RC and get the following when attempting to run Storybook in dev mode.
I'm using the following packages:
Not a problem, it's an RC after all. |
@valentinpalkovic @shilman After spending some more time debugging, I have found the cause of this: if the component consumes any kind of server action that invokes 'use server';
import { headers } from "next/headers";
export const dummyServerAction = async () => {
// NOTE: This is the line that wiill causes Storybook to fail
// If you comment it out and replace with the line below, Storybook will work:
// const referrer = 'http://localhost:6006/';
const referrer = (await headers()).get('referer');
return {
message: 'Server action was successful',
referrer,
}
} I have successfully reproduce the issue below with this repo: |
Describe the bug
As Next.js RC for v15 has been released for testing, I'm investigating if it is possible to perform an upgrade of a Next.js app containing a storybook from
next@14
to[email protected]
. When attempting to build a storybook (usingstorybook build
), I encounter this error:I suspect this is likely due to the breaking changes made to the folder structure inside
node_modules/next/dist
. The release candidate no longer has the nested folder structure the@storybook/nextjs
depends on.This can be reproduced if any component consumed by Storybook invokes a server action in nextjs that uses the dynamic API, e.g.
cookies()
orheaders()
:Reproduction link
https://github.com/terrymun/nextjs15-storybook
Reproduction steps
Running
storybook build
with next@15 release candidate should not fail with the message:I am unfortunately unable to reproduce this with an example from storybook.new, but I can confirm that inspecting the code in
@storybook/nextjs
does uncover statements that points to a file fornext@14
, but not to a file in[email protected]
: https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/src/export-mocks/headers/index.ts#L3C1-L6C53System
Additional context
No response
The text was updated successfully, but these errors were encountered: