brumbrum_brum
brumbrum_brum5mo ago

Procedures with paramters.

Is it possible to pass parameters to a procedure in TRPC? I want a procedure that first checks if the user is signed in by default. But then I also want to be able to pass an array of permissions for the user to have, when the actual procedure is used in a route.
7 Replies
MadaShindeInai
MadaShindeInai5mo ago
You can pass any data to context and then access it in procedure
brumbrum_brum
brumbrum_brumOP5mo ago
Do you know of any examples of doing this?
MadaShindeInai
MadaShindeInai4mo ago
I'm doing this 🙂 But you can check T3-app + Clerk.io integration example. They pass Clerk auth there.
George
George4mo ago
Yeh I was able to do this, by creating a function that accepts an array of user permissions and returns a trpc middleware:
George
George4mo ago
No description
George
George4mo ago
Then I can use it like this
No description
George
George4mo ago
I am not sure if this is a good approach or not, but it works well