-
SummaryI'm building a Next js app using tRPC, and I’m fetching some data on the server with What’s the cleanest pattern for syncing the server-rendered data with client-side updates in this setup? Ideally with support for optimistic updates and revalidation, but without overcomplicating things. Any suggestions or examples would be appreciated! Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey! I havve faced this exact scenario with tRPC + Next.js, so here’s a pattern that works well and is quite common practice: 1. Use
|
Beta Was this translation helpful? Give feedback.
Hey! I havve faced this exact scenario with tRPC + Next.js, so here’s a pattern that works well and is quite common practice:
1. Use
getServerSideProps
for initial loadFetch your data via your tRPC caller and pass it down as props:
2. Hydrate tRPC’s useQuery with initial data
3. Use a mutation + optimistic update pattern