tRPC with ssr: true - what's going on?
I've looked far and wide, and haven't figured this out.
ssr: true
uses getInitialProps
, instead of getServersideProps
, which can result in faster page loads since we're not waiting on the server. However, getServersideProps
is now the recommended solution.
putting ssr: false
feels wrong as it seems like this means I won't get ssr. I imagine this is wrong? Is the ssr that trpc is referring to different from the ssr we do want as described in the next js docs?1 Reply
suppose we have to make a query for page data, it seems our options are
ssr: false
and getServersideProps
which does ssr but doesn't give you the page with a loading state.
OR, ssr: true
and use trpc useQuery on the client which will (on first page load) seamlessly run the request on the server without having to define getInitialProps
or getServersideProps
?
i've tried setting ssr: true
with requests on the client and it does indeed wait for the request before rendering the page but then it requests the page again on rehydration! Does ssr: true
also mean i'm going to run all those requests twice