mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### Description Follow up #35349. 1. Update the [example template](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) with [StackBlitz](https://stackblitz.com/) preview 2. Add `preview live with StackBlitz` to the examples 3. Remove the below old StackBlitz preview section from the examples ```md ## Preview Preview the example live on [StackBlitz](http://stackblitz.com/): [](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/active-class-name) ``` CC: @samcx ### Improving Documentation - [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - [x] The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - [x] Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
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
Deploy the example using Vercel or preview live with StackBlitz
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.