mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
Next.js example with graphql-react
graphql-react is a GraphQL client for React using modern context and hooks APIs that is lightweight (< 3 KB size limited) but powerful; the first Relay and Apollo alternative with server side rendering.
Deploy your own
How to use
Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:
npx create-next-app --example with-graphql-react with-graphql-react-app
yarn create next-app --example with-graphql-react with-graphql-react-app
pnpm create next-app --example with-graphql-react with-graphql-react-app
Deploy it to the cloud with Vercel (Documentation).
Notes
- In
pages/_app.jsa customAppcomponent is decorated with thewithGraphQLApphigher-order component fromnext-graphql-react, generating agraphqlprop that populates theGraphQLProvidercomponent fromgraphql-react. - In
pages/index.jstheuseGraphQLReact Hook fromgraphql-reactis used to query the GraphQL Pokémon API and show a picture of Pikachu.