Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nextjs16-optimizedeps-navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-storybook-nextjs": patch
---

Fix missing Next.js 16 internal exports (`ServerInsertedHTMLContext`, `RedirectStatusCode`) in Vite dev mode by adding `next/navigation` and `next/dist/client/components/redirect-error` to `optimizeDeps.include` for Next.js 16+. See [storybookjs/storybook#34688](https://github.com/storybookjs/storybook/issues/34688).
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ function VitePlugin({
? ["@emotion/react/jsx-dev-runtime"]
: []),
...(isNext16orNewer ? [] : ["next/config"]),
// Next.js 16 ships internal re-export chains that Vite's esbuild
// pre-bundler fails to resolve in dev mode, causing missing exports
// like ServerInsertedHTMLContext and RedirectStatusCode. Forcing
// these modules to be pre-bundled fixes the resolution.
// See: https://github.com/storybookjs/storybook/issues/34688
...(isNext16orNewer
? [
"next/navigation",
"next/dist/client/components/redirect-error",
]
: []),
],
},
test: {
Expand Down
Loading