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
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.@Brendonovich thank you very much!
@Brendonovich I am sorry for bothering you how can I call the trpc inside SSR?
By SSR do you mean inside
getServerSideProps
?Yes sir
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.
useQuery uses react context and stuff, which you don't want to use in gSSP
amazing, thank you again!