fix(plugin-nextra): move next/react to peerDependencies for Next 14-16 + React 18/19#1025
Merged
Conversation
…pport Next 14-16 + React 18/19 next/react/react-dom were hard dependencies in a component library, risking a duplicate-React runtime (Invalid hook call) for consumers that already provide their own React/Next. Move them to peerDependencies with broad ranges (Next 14/15/16, React 18/19) so the plugin supports the latest frameworks without forcing a second copy on existing users. Add a tsc --noEmit typecheck wired as the package test so CI actually verifies framework compatibility (the swc build never type-checked). Switch tsconfig to bundler resolution (Next-recommended; nodenext mis-resolves next/link's default export) and use the canonical next/link specifier. Supersedes #1009, which bumped next as a hard dependency without these fixes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #1009. Dependabot #1009 bumped
next14→16 as a hard dependency, which is the wrong fix for a component library and would break consumers. This PR makes@orama/plugin-nextracompatible with the latest frameworks the correct way — viapeerDependencies— with zero behavioral change, and adds a real typecheck so CI actually verifies compatibility.Problem
next,react, andreact-domwere declared as harddependencies. For a plugin that renders inside a host Nextra/Next app, that bundles a second copy of React/Next under the consumer → duplicate-React "Invalid hook call" and auseRouterthat reads a different runtime than the host's router. Bumpingnextto 16 as a hard dep (as #1009 does) makes it worse: it nests Next 16 under consumers still on 14, and pins React 18 while Next 16 requires React 19. None of this is caught today because the package builds with swc (no typecheck) and has no tests — so the broken peer state is false-green in CI.Fix
Move
next/react/react-domfromdependencies→peerDependencieswith broad ranges:next:^14.2.30 || ^15.0.0 || ^16.0.0react/react-dom:^18.3.1 || ^19.0.0Supports the latest frameworks and keeps every existing React-18 / Next-14 user working — nobody is dropped.
Add them (Next 16, React 19) as
devDependenciesso the package is type-checked against the hardest target.Add a real test —
"test": "tsc --noEmit"— so CI verifies framework compatibility instead of only transpiling.Switch
tsconfigtomoduleResolution: "bundler"(the Next.js-recommended setting;nodenextmis-resolvesnext/link's default export under Next 16) and use the canonicalnext/linkspecifier. No runtime/behavioral change — swc output and component behavior are identical.Compatibility matrix
Source needed zero API changes — every Next/React API the plugin uses (Pages-Router
useRouter,next/compat/router, modernnext/link, stable React hooks) is supported across all of the above.Validation (local)
pnpm build— 18/18 packages green, includingplugin-docusaurus-v3'stscbuild against React 19 (confirms no ripple to other packages).tsc --noEmit(the new test) — green against Next 16 + React 19.next/router,next/compat/router,next/linkall resolve under Next 16.plugin-nextrais the only Next consumer; the lockfile delta is smaller than chore(deps): bump next from 14.2.32 to 16.1.5 #1009's and leaves docusaurus's React resolution unchanged.Note for consumers
This is a Pages-Router plugin; its real consumers are Nextra 1/2/3 (Pages Router) sites. Nextra 4 is App-Router-only and ships its own search, so it neither needs nor uses this plugin.
Closes #1009.