Nickelback Plays Music

    next-graphql-react

    12.0.0 • Public • Published

    graphql-react logo

    next-graphql-react

    npm version CI status

    A graphql-react integration for Next.js.

    Installation

    To install next-graphql-react and its graphql-react peer dependency with npm, run:

    npm install next-graphql-react graphql-react

    Within pages/_app.js:

    1. Polyfill the required globals.
    2. Use the withGraphQLReact decorator to setup a Next.js custom App.

    Then the graphql-react React hooks can be used within your Next.js pages and components.

    Examples

    Requirements

    • Node.js: ^12.22.0 || ^14.17.0 || >= 16.0.0
    • Browsers: > 0.5%, not OperaMini all, not IE > 0, not dead

    API

    function withGraphQLReact

    A Next.js custom App React component decorator that returns a higher-order React component that enables the graphql-react React hooks within children for loading and caching data that can be server side rendered and hydrated on the client.

    After waterfall rendering for a server side render, cache values are scanned for a response property (which should be non-enumerable so it won’t be included in the serialized JSON sent to the client for hydration) that is a Response instance. Any of the following HTTP Link headers found in the responses are deduped and forwarded to the client in 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 React component.

    Returns: withGraphQLReact~WithGraphQLReact — Next.js custom App higher-order React component.

    See

    Examples

    How to import.

    import withGraphQLReact from "next-graphql-react/withGraphQLReact.mjs";

    A Next.js custom App.

    In pages/_app.js:

    import withGraphQLReact from "next-graphql-react/withGraphQLReact.mjs";
    import App from "next/app";
    
    export default withGraphQLReact(App);

    Install

    npm i next-graphql-react

    DownloadsWeekly Downloads

    221

    Version

    12.0.0

    License

    MIT

    Unpacked Size

    17.3 kB

    Total Files

    3

    Last publish

    Collaborators

    • jaydenseric