Miss any of our Open RFC calls?Watch the recordings here! »

next-graphql-react

8.0.1 • Public • Published

graphql-react logo

next-graphql-react

npm version CI status

A graphql-react integration for Next.js to enable server side rendered GraphQL operations.

Setup

To install next-graphql-react and the graphql-react peer dependency from npm run:

npm install next-graphql-react graphql-react

See the withGraphQLApp examples to get started.

Examples

Support

API

Table of contents

function withGraphQLApp

A higher-order React component to decorate a Next.js custom App component in pages/_app.js for graphql-react, enabling descendant GraphQL operations with server side rendering and client side data hydration.

It also forwards HTTP Link headers with the following rel parameters from GraphQL responses received when ssr runs to the Next.js page response:

Link URLs are forwarded unmodified, so avoid sending relative URLs from a GraphQL server hosted on a different domain to the app.

Parameter Type Description
App object Next.js custom App component.

Returns: WithGraphQL — Next.js custom App higher-order component.

See

Examples

Ways to import.

import { withGraphQLApp } from 'next-graphql-react';
import withGraphQLApp from 'next-graphql-react/universal/withGraphQLApp.js';

Ways to require.

const { withGraphQLApp } = require('next-graphql-react');
const withGraphQLApp = require('next-graphql-react/universal/withGraphQLApp');

A custom App.

In pages/_app.js:

import { GraphQLProvider } from 'graphql-react';
import { withGraphQLApp } from 'next-graphql-react';
import React from 'react';
 
const App = ({ Component, pageProps, graphql }) => (
  <GraphQLProvider graphql={graphql}>
    <Component {...pageProps} />
  </GraphQLProvider>
);
 
export default withGraphQLApp(App);

Install

npm i next-graphql-react

DownloadsWeekly Downloads

474

Version

8.0.1

License

MIT

Unpacked Size

20.4 kB

Total Files

6

Last publish

Collaborators

  • avatar