nehalist
nehalist3y ago

tRPC without SSR

When using tRPC with ssr it uses getInitialProps, which has kinda of a cool effect in terms how a page is rendered, since it's rendered server-side on initial requests and client-side on route transitions. Unfortunately, enabling ssr means that you can no longer use getServerSideProps (which I know is only fixable by next.js and not tRPC). But how to replicate the getInitialProps behaviour then? Let's say I'm building a blog; due to SEO it's basically necessary to render my posts server-side. But when navigating through the site loading posts on the fly would be totally fine. How to do that without ssr?
12 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Alex / KATT 🐱
Response Caching | tRPC
The below examples uses Vercel's edge caching to serve data to your users as fast as possible.
Alex / KATT 🐱
Server-Side Rendering | tRPC
To enable SSR just set ssr: true in your createTRPCNext config callback.
Alex / KATT 🐱
all info should be in those 2 pages
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Alex / KATT 🐱
You can use gSSP if you prefer all route changes to be slowed down RSC will come soon and hopefully fix all this stuff.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Alex / KATT 🐱
Fwiw, benefit to not using our ssr is to be able to use Suspense
Alex / KATT 🐱
Suspense (Experimental) | tRPC
- useSuspense & useSuspenseInfiniteQuery are experimental features as its implementation may change as a result of the use() proposal & RSC (React Server Components)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Alex / KATT 🐱
umm if you're okay with doing an SPA, yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View