Server Side Redirect based on tRPC/Prisma query

How can I redirect before page load based on a tRPC/Prisma query? I have a table which I need to check against, before I can decide whether to redirect or not. Sorry if the question might be stupid - bit of a tRPC/Prisma newbie here. Thanks!
7 Replies
cje
cje2y ago
If you’re saying “before page load” does that mean you’re calling the query from gSSP?
riccardolardi
riccardolardiOP2y ago
Yes that's what I was planning to do
cje
cje2y ago
Christopher Ehrlich
YouTube
Advanced tRPC - Callers, functions, and gSSP
Repo for this video: https://github.com/c-ehrlich/you-dont-need-callers If you want to use schema in the frontend, they cannot be imported from the same file as things that run specifically in the backend. One solution would be to put them into a procedureName.schema.ts or similar file. tRPC: https://trpc.io/docs Create T3 App: https://crea...
cje
cje2y ago
Gssp has “redirect” as a thing you can return
riccardolardi
riccardolardiOP2y ago
@cje I know but I don't know how to call tRPC/Prisma query from gSSP
cje
cje2y ago
Ssg helpers It’s in the video (Ssg helpers is a terrible name and will be changed soon, they work for ssr also)
riccardolardi
riccardolardiOP2y ago
Ok thanks a lot I'll check it out!
Want results from more Discord servers?
Add your server