Skip to content

fix(plugin-nextra): move next/react to peerDependencies for Next 14-16 + React 18/19#1025

Merged
thatjuan merged 1 commit into
mainfrom
fix/plugin-nextra-peer-deps
Jun 27, 2026
Merged

fix(plugin-nextra): move next/react to peerDependencies for Next 14-16 + React 18/19#1025
thatjuan merged 1 commit into
mainfrom
fix/plugin-nextra-peer-deps

Conversation

@thatjuan

Copy link
Copy Markdown
Contributor

Summary

Supersedes #1009. Dependabot #1009 bumped next 14→16 as a hard dependency, which is the wrong fix for a component library and would break consumers. This PR makes @orama/plugin-nextra compatible with the latest frameworks the correct way — via peerDependencies — with zero behavioral change, and adds a real typecheck so CI actually verifies compatibility.

Problem

next, react, and react-dom were declared as hard dependencies. 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 a useRouter that reads a different runtime than the host's router. Bumping next to 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-dom from dependenciespeerDependencies with broad ranges:

    • next: ^14.2.30 || ^15.0.0 || ^16.0.0
    • react / react-dom: ^18.3.1 || ^19.0.0

    Supports the latest frameworks and keeps every existing React-18 / Next-14 user working — nobody is dropped.

  • Add them (Next 16, React 19) as devDependencies so 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 tsconfig to moduleResolution: "bundler" (the Next.js-recommended setting; nodenext mis-resolves next/link's default export under Next 16) and use the canonical next/link specifier. No runtime/behavioral change — swc output and component behavior are identical.

Compatibility matrix

React 18 React 19
Next 14
Next 15
Next 16

Source needed zero API changes — every Next/React API the plugin uses (Pages-Router useRouter, next/compat/router, modern next/link, stable React hooks) is supported across all of the above.

Validation (local)

  • pnpm build — 18/18 packages green, including plugin-docusaurus-v3's tsc build against React 19 (confirms no ripple to other packages).
  • tsc --noEmit (the new test) — green against Next 16 + React 19.
  • Deep-import smoke — next/router, next/compat/router, next/link all resolve under Next 16.
  • plugin-nextra is 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.

…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.
@thatjuan thatjuan merged commit 59fa064 into main Jun 27, 2026
2 checks passed
@thatjuan thatjuan deleted the fix/plugin-nextra-peer-deps branch June 27, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant