Next 12.2 newNextLinkBehavior support
See original GitHub issueDescribe the bug
Next.js 12.2 support new link behavior.
From https://nextjs.org/blog/next-12-2#other-improvements
next/link no longer requires manually adding as a child. You can now opt into this behavior in a backward-compatible way.
https://github.com/vercel/next.js/pull/36436
I added the newNextLinkBehavior flag in my next config in next.config.js
{
experimental: {
newNextLinkBehavior: true,
}
}
but when I use storybook with the new link behavior it seems to not understand it.
I get
Multiple children were passed to <Link> with `href` of `/` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children
error although in my app this resolves well.
Your minimal, reproducible example
nextjs example with-storybook-app
Steps to reproduce
- Add
{
experimental: {
newNextLinkBehavior: true,
}
}
to next.config.js.
2. Create a component with multiple children inside Link like
import Link from "next/link";
export function MenuItem() {
return (
<Link href="/" >
<div/>
<div/>
</Link>
);
}
- Use this component in storybook story
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { MenuItem } from "./MenuItem";
export default {
component: MenuItem,
} as ComponentMeta<typeof MenuItem>;
const Template: ComponentStory<typeof MenuItem> = (args) => (
<MenuItem {...args} />
);
export const Regular = Template.bind({});
Expected behavior
No error will occur and the new link behavior will be supported
How often does this bug happen?
Every time
Screenshots or Videos

Platform
MacOS Monterey 12.4 Chrome Version 103.0.5060.114 (Official Build) (arm64)
storybook-addon-next version
^1.6.7
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Blog - Next.js 12.2
Next.js 12.2 introduces stable Middleware and On-Demand ISR, experimental Edge SSR and API Routes, and more!
Read more >Why are /de-DE routes with i18n Next.js returning a 500?
Here's the site: TaxPal - Accounting made simple for small businesses Removing /de-DE from the url works fine It seems to work fine...
Read more >How to enable NextJS "next/future/image"? - Stack Overflow
json to "next": "^12.2.0" . Here's my next.config.js file: /** @type {import('next ...
Read more >next: Versions | Openbase
Add support for next.js development in docker: #43138. Credits ... Set __NEXT_NEW_LINK_BEHAVIOR in Jest tests when newNextLinkBehavior is true: #40702 ...
Read more >12.2.5 - next - npm
next. TypeScript icon, indicating that this package has built-in type declarations. 12.2.5 • Public • Published 4 months ago.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@nirtamir2 seems like this addon doesn’t pass down
experimentaloptions, found a workaround to work withnewNextLinkBehavior💪in your
preview.tsxfile add the following@B2o5T Thanks, that fixed it for me!