what would be the best way to refetch state that I got via getServerSideProps using TRPC?
Currently I'm passing in initial state from serverSideProps, just using prisma client to make the fetch. But then when a user makes a new post, I want to update the list of posts that the user sees. Issue is, I have nothing to refetch
8 Replies
You can return the dehydrated state itself (not the response)
The you just use hooks as usual
They fetch on server side tho
But you have access to methods like refetch
SSG Helpers | tRPC
createProxySSGHelpers provides you a set of helper functions that you can use to prefetch queries on the server.
so i still write trpc call on server side?
Yes, but you don't use the response, just pass the state
tRPC then uses it and does not call the API the second time
So you have SSR but with access to the request hook on frontend
Just like in the example I sent
aha
that makes sense
pretty cool stuff, thanks
No problem
so what do i have to pass to the Context in this case?
in the example it takes no params, but the context ive imported requires a parameter; assuming it has something to do with the next context stuff?
If your API call depends on the context you have to pass it