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
If you’re saying “before page load” does that mean you’re calling the query from gSSP?
Yes that's what I was planning to do
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...Gssp has “redirect” as a thing you can return
@cje I know but I don't know how to call tRPC/Prisma query from gSSP
Ssg helpers
It’s in the video
(Ssg helpers is a terrible name and will be changed soon, they work for ssr also)
Ok thanks a lot I'll check it out!