Accessing req & res in Trpc + Next.js
Total beginner question. Would love to move my next.js project over to trpc, but am having problems getting started.
How would I access
req
& res
objects in NextJS with trpc?
My current code / function starts like this:
Now, I'm trying to do the same thing, but with trpc:
7 Replies
you get data from input
and return data in the return statement
if you need req or res for something else, you can go into the function where context is created and pass them there
but i'd recommend to try without first
yeah, tRPC is a different paradigm from REST, if you think you need req/res you're probably doing something wrong
Oh damn, I didn't know that it's totally different in this regard
you might need it occasionally if you're doing some weird stuff with headers or something
have you read the docs at all?
Quickstart | tRPC
We highly encourage you to check out the Example Apps to get a feel of tRPC and getting up & running as seamless as possible.
read through this
thanks