A higher-order component (HOC) that integrates Apollo Client with Next.js for seamless GraphQL data fetching.
next-with-apollo is a higher-order component (HOC) that integrates Apollo Client with Next.js applications. It simplifies setting up GraphQL data fetching by wrapping pages with ApolloProvider, supporting both client-side and server-side rendering. The library helps developers manage Apollo Client configuration while preserving Next.js optimizations like Automatic Static Optimization.
Next.js developers building applications that require GraphQL data fetching with Apollo Client, especially those needing SSR or static generation support.
Developers choose next-with-apollo for its straightforward API that reduces boilerplate when combining Apollo Client and Next.js. It offers flexibility in configuration, maintains Next.js performance features by default, and provides clear migration paths across different Next.js versions.
Apollo HOC for Next.js
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
It reduces boilerplate by providing a HOC that automatically wraps pages with ApolloProvider, as shown in the basic setup example using apollo-boost.
Supports optional getDataFromTree configuration for server-side rendering of GraphQL queries, enabling SEO-friendly pages without loading states, detailed in the API section.
Maintains Next.js Automatic Static Optimization by default unless explicitly overridden with SSR settings, which the README emphasizes to avoid unnecessary lambda functions.
Offers clear versioning for different Next.js releases, such as specifying v3.4.0 for Next v6-v8, helping developers avoid migration issues.
Enabling getDataFromTree disables Automatic Static Optimization, turning pages into serverless functions and potentially slowing initial renders, as warned in the README's performance notes.
Errors during SSR are silently ignored unless the onError callback is provided, adding complexity for developers who need robust error management in production.
The library's utility is tied to Apollo Client's API; breaking changes in Apollo or Next.js may require updates or cause compatibility issues, as seen in the migration guide from version 4.3.0.