Is my approach correct to publish posts as 'published .. time ago' and SSR or tRPC?

I want to get my posts from SSR and what is the best way to get them? Can I use tRPC route calls inside SSR or should I call the prisma client from SSR?
8 Replies
Brendonovich
Brendonovich2y ago
For SSR you can do either approach . Consider moving publishedTimeAgo to the frontend, since doing it on the backend can make it harder to manage i18n for languages other than the one you've written.
Çağlar
Çağlar2y ago
@Brendonovich thank you very much! @Brendonovich I am sorry for bothering you how can I call the trpc inside SSR?
Brendonovich
Brendonovich2y ago
By SSR do you mean inside getServerSideProps?
Çağlar
Çağlar2y ago
Yes sir
Çağlar
Çağlar2y ago
Brendonovich
Brendonovich2y ago
for gSSP in particular you'll wanna look at the static generation helpers: https://trpc.io/docs/ssg-helpers
SSG Helpers | tRPC
createProxySSGHelpers provides you with a set of helper functions that you can use to prefetch queries on the server.
Brendonovich
Brendonovich2y ago
useQuery uses react context and stuff, which you don't want to use in gSSP
Çağlar
Çağlar2y ago
amazing, thank you again!
Want results from more Discord servers?
Add your server