trpc call inside getServerSideProps?
(create-t3-turbo) I have a dynamic route for users' stuff,
stuff/xyz
they can they go to stuff/xyz/doStuff
or stuff/xyz/doOtherStuff
I need to validate xyz
that it exists in my DB - then redirect to 404 if fails, so far ive done it with prisma client directly (inspired from zapdos kinda)
which works fine tbh - but i dont like how i need to import { Stuff } from ".prisma/client";
for my prop type and how im not using trpc for this (tbh) - is there a way to use trpc here or simply a better way?
does it make sense to just trpc in client and redirect on useEffect + useRouter?8 Replies
kind bump on this
SSG Helpers | tRPC
createProxySSGHelpers provides you with a set of helper functions that you can use to prefetch queries on the server.
What I found way easier than SSG Helpers is just restructuring your TRPC endpoint to be a proxy in a sense. All my logic inside my trpc handlers are abstracted to a different file so I can simply call that function server side from nextjs
do you have a public repo or examples please?
you literally just write a function and call it
trpc and gssp both run on the server
so they can call the same functions
aight will try that for now - ssg didnt work for me as my content behind dynamic route is very specific to users and doesnt make sense ssg it? at least it is painfully slow and cant be built/cached or smth?
thanks both
it just looks cool when u trpc all the way 😄
if its very user specific you cant ssg it
or you can ssg the static bits and then hydrate a query or something like that
btw ssg helpers work in ssr also
im at my depth, this is a very tricky use case i guess? would u be intersted in hearing details maybe u could help me figure out the missing piece