next/link: legacyBehavior deprecation #82804
Replies: 3 comments 1 reply
-
Agreed, the legacyBehavior prop is essential for allowing custom components from (non-nextjs) React component libraries. |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity, what are the component libraries that do not work without Not having |
Beta Was this translation helpful? Give feedback.
-
A little update: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
With the latest Next.js there is now a runtime error suggesting that legacyBehavior flag is going to be removed and suggesting to use a codemod to migrate. The codemod however just drops this property without any alternative solution.
There were multiple issues / discussions with people asking questions about the alternatives in the past. All solutions I've seen so far recommend either implementing polymorphic rendering implement in the component (as={Link} or asChild) or using next/link inside the component itself.
However, there are no answers about what should be an alternative when these components come from a 3rd party design system that can't have Next.js as a dependency and/or don't support as/asChild. Just ignoring this problem and using the codemod results in the design system button (and other navigation component) to be wrapped with an and either end up having 2 nested tags or end up losing correct focus styles.
I hope we can have this resolved before it gets completely dropped in the next major and would be nice if we can have a way to disable the runtime error meanwhile.
Beta Was this translation helpful? Give feedback.
All reactions