Example project with Next.js & gqless (graphql client)
MIT License
This app is an example of how to use gqless with Next.js. It mirrors the with-apollo Next.js example app. Apollo examples are included here for comparison.
withGqless
& useGqless
) into your project
react-ssr-prepass
package (actually @zen_flow/react-ssr-prepass
untilgetClient
function to gqless/client.ts
.export const createClient = (queryFetcher = fetchQuery) => new Client<Query>(schema.Query, queryFetcher);
withGqless
HOC on the Next.js pages you want SSR'd. This will add a React context providergetInitialProps
to prefetch the necessary data before displaying the page.useGqless
hook to access the gqless client
(and query
) from context (in components that will be SSR'd).client
(or query
) exported from Client.ts
for SSR because on the server we want to have oneSsrCompatibleSuspense
Suspense
component.<Suspense/>
is encountered during SSR.