-
I'm using next-urql in a project and have a global layout on my _app.js which needs to access the graphql client, however, according to the documentation, wrapping my _app.js with withUrqlClient will stop next.js' static optimization from working correctly. Is there any other way of being able to access the urql client from my Sidebar component? function MyApp({ Component, pageProps }) {
return (
<ThemeProvider theme={theme}>
<div>
<Sidebar />
<Component {...pageProps} />
</div>
</ThemeProvider>
);
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
So I’m not quite sure I understand your goals here. Accessing the client under a So I suppose your question is: How do I query data and use static optimisations? The answer to that is more complicated, because the static optimisation API in Next.js doesn’t really take this into account at all. If you have You can still use the manual method to define static pages: https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation But alternatively you’ll have to use This is a limitation of Next.js in how it tries to prerender pages, since it won’t assume that |
Beta Was this translation helpful? Give feedback.
So I’m not quite sure I understand your goals here.
Accessing the client under a
Provider
like withwithUrqlClient
is as easy as using the hooks or using the context withuseClient
.So I suppose your question is: How do I query data and use static optimisations? The answer to that is more complicated, because the static optimisation API in Next.js doesn’t really take this into account at all.
If you have
next-urql
set up for SSR it’ll do so usinggetInitialProps
. If you have a page with it that means that page won’t automatically be statically rendered, if you have it on_app
that means no page will automatically be statically rendered.You can still use the manual method to define static…