{"id":16186228,"url":"https://github.com/zenflow/next-with-gqless-example","last_synced_at":"2025-03-19T03:30:28.193Z","repository":{"id":42888772,"uuid":"253974838","full_name":"zenflow/next-with-gqless-example","owner":"zenflow","description":"Example project with Next.js \u0026 gqless (graphql client)","archived":false,"fork":false,"pushed_at":"2023-01-06T03:08:35.000Z","size":1317,"stargazers_count":5,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T14:44:21.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://next-with-gqless-example.now.sh/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-08T03:23:13.000Z","updated_at":"2023-08-18T15:29:40.000Z","dependencies_parsed_at":"2023-02-05T04:32:24.467Z","dependency_job_id":null,"html_url":"https://github.com/zenflow/next-with-gqless-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fnext-with-gqless-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fnext-with-gqless-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fnext-with-gqless-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fnext-with-gqless-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenflow","download_url":"https://codeload.github.com/zenflow/next-with-gqless-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243961595,"owners_count":20375276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:17:37.437Z","updated_at":"2025-03-19T03:30:27.902Z","avatar_url":"https://github.com/zenflow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# next-with-gqless-example\n\nThis app is an example of how to use [gqless](https://gqless.dev/) with [Next.js](https://nextjs.org/).\nIt mirrors [the with-apollo Next.js example app](https://github.com/zeit/next.js/tree/canary/examples/with-apollo).\nApollo examples are included here for comparison.\n\n## [Live demo](https://next-with-gqless-example.now.sh/).\n\n## The Gist\n\n1. Copy boilerplate code from [./lib/gqless.js](https://github.com/zenflow/next-with-gqless-example/blob/master/lib/gqless.js) (including `withGqless` \u0026 `useGqless`) into your project\n    1. Copy the file\n    2. Install the required `react-ssr-prepass` package (actually `@zen_flow/react-ssr-prepass` until\n    [this patch](https://github.com/FormidableLabs/react-ssr-prepass/pull/51) is released).\n    3. Add the required `getClient` function to `gqless/client.ts`.\n      ```\n      export const createClient = (queryFetcher = fetchQuery) =\u003e new Client\u003cQuery\u003e(schema.Query, queryFetcher);\n      ```\n2. Use the `withGqless` HOC on the Next.js pages you want SSR'd. This will add a React context provider\nfor the gqless client and wrap `getInitialProps` to prefetch the necessary data before displaying the page.\n3. Use the `useGqless` hook to access the gqless `client` (and `query`) from context (in components that will be SSR'd).\nWe cannot use the singleton `client` (or `query`) exported from `Client.ts` for SSR because on the server we want to have one\nclient per request.\n4. Use [`SsrCompatibleSuspense`](https://github.com/zenflow/next-with-gqless-example/blob/master/lib/SsrCompatibleSuspense.js)\ninstead of the regular React `Suspense` component.\nThis will stop ReactDOMServer from complaining and crashing when `\u003cSuspense/\u003e` is encountered during SSR.\nThe caveat here is that React will log warnings when rehydrating browser-side, since what's rendered on browser is\nsupposed to match what was rendered on the server. (Issue [#2](https://github.com/zenflow/next-with-gqless-example/issues/2))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenflow%2Fnext-with-gqless-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenflow%2Fnext-with-gqless-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenflow%2Fnext-with-gqless-example/lists"}