next/link: legacyBehavior deprecation #82804
Unanswered
blvdmitry
asked this question in
App Router
Replies: 1 comment
-
Agreed, the legacyBehavior prop is essential for allowing custom components from (non-nextjs) React component libraries. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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