mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
eb24e6ffc6
Adds an example with [`graphql-react`](https://github.com/jaydenseric/graphql-react), using [`next-graphql-react`](https://github.com/jaydenseric/next-graphql-react). [`graphql-react`](https://github.com/jaydenseric/graphql-react) is a lightweight but powerful [GraphQL](https://graphql.org) client for React; the first [Relay](https://facebook.github.io/relay) and [Apollo](https://apollographql.com/docs/react) alternative with server side rendering. |
||
---|---|---|
.. | ||
pages | ||
package.json | ||
README.md |
Next.js example with graphql-react
graphql-react
is a lightweight but powerful GraphQL client for React; the first Relay and Apollo alternative with server side rendering.
See how it can be used in a Next.js app for GraphQL queries with server side rendering and client side data hydration:
- In
pages/_app.js
a customApp
component is decorated with thewithGraphQL
higher-order component fromnext-graphql-react
, generating agraphql
prop that populates theProvider
component fromgraphql-react
. - In
pages/index.js
theQuery
component fromgraphql-react
is used to query the GraphQL Pokémon API and show a picture of Pikachu.
Setup
-
Download the example:
curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-graphql-react
-
Change directory to it:
cd with-graphql-react
-
Install it:
npm install
-
Run it:
npm run dev