[next-urql] Using SSR with both withUrqlClient and getServerSideProps #1091
-
I have a page that looks something like this const Index = () => //...
export const getServerSideProps = async (ctx) => {
const session = await getSession(ctx)
return {
props: {
session
}
}
}
export default withUrqlClient((ssr, ctx) => {
url: process.env.NEXT_PUBLIC_GRAPHQL_API_URL,
suspense: false
}, { ssr: true })(Index) Since I'm not using getInitialProps I have to set
Is there a way to use getServerSideProps and have SSR? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
They can't be used together for several reasons, the intent is different. With If you want to use The choice comes down to: We as authors of these libraries don't really have a lot of "power" over these exported functions since they're more of a build-time thing than anything else. Do note that you don't lose out on |
Beta Was this translation helpful? Give feedback.
They can't be used together for several reasons, the intent is different. With
next-urql
we want to enable you to resolveuseQuery
calls. We use the V-DOM tree to resolve the query-hooks you got there, this means that we have to addgetInitialProps
to the page to run aprepass
on it.If you want to use
getServerSideProps
you'll have to turnssr: false
that means we don't bindgetInitialProps
to the page component you are wrapping inwithUrql
and we'll instead just inject theProvider
.The choice comes down to:
do you want to have that one
getServerSideProps
call or do you want to resolve your full tree ofuseQuery
?We as authors of these libraries don't really have a lot of "power" over t…