Server side trpc call
Hi,
In the attached picture, I am passing username from getserverside props down to my Profile page and I am doing a trpc call to query my db to check if the user exists. This works but I am currently displaying 'user not found' then displaying the user if they exist. I would like to carry out this call on the server so that I can avoid the lag and can display the user or 'user not found' instantly.
Do you have any suggestions or tips on how I can carry this out?

13 Replies
do the query serverside
SSG Helpers | tRPC
createProxySSGHelpers provides you a set of helper functions that you can use to prefetch queries on the server.
Thank you for the reply! I am following the documentation and it seems like createContext() expects 'opts' arguments... Do you have any idea what I should pass as the argument in order to initialize ssg


Whatever the function you’re calling expects, possibly just an empty object


Its expecting (opts: CreateNextContextOptions)

^ yea that
You can’t use regular createContext because you don’t have req and res
createContextInner
I don't see createContextInner
anywhere in docs though.
<:bing_shrug:583791581497393162>You guys are legends
That worked for me
I will continue and see if I can pre load the fetch in the server