A Next.js integration for the graphql-react library providing server-side rendering and automatic GraphQL cache hydration. Version 16.0.0 supports Next.js 12-14, React 18, and requires graphql-react 20.0.0 as a peer dependency. It is ESM-only, requires specific TypeScript configuration, and uses deep imports from individual .mjs modules. Designed for optimal module tree-shaking and modern Node.js (^18.17.0 || >=20.4.0).
npm install next-graphql-reactNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to wrap a Next.js custom App with withGraphQLReact and use useGraphQL hook in a page. Uses ESM imports with .mjs extension.
Use deep imports like 'next-graphql-react/withGraphQLReact.mjs' instead of 'next-graphql-react'.
Check peer dependency compatibility; Next.js 15 not supported yet.
Set compilerOptions: { allowJs: true, maxNodeModuleJsDepth: 10, module: 'node16' }Install cross-fetch or similar and import it in _app.mjs before the App component.
Update Node.js to ^18.17.0 || >=20.4.0 and ensure your Browserslist target is compatible.
Import useGraphQL, Cache, etc. from the graphql-react package directly.
Change import to 'next-graphql-react/withGraphQLReact.mjs'.
Ensure your bundler (e.g., Next.js) is configured to handle .mjs files (Next.js does by default with experimental esmExternals: 'loose' if needed).
Use deep import 'next-graphql-react/withGraphQLReact.mjs' and ensure you're importing the named export.
Set compilerOptions.module to 'node16' or 'nodenext' in tsconfig.json.