brumbrum_brum
brumbrum_brum3mo 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
MadaShindeInai3mo ago
You can pass any data to context and then access it in procedure
brumbrum_brum
brumbrum_brum3mo ago
Do you know of any examples of doing this?
MadaShindeInai
MadaShindeInai2mo ago
I'm doing this 🙂 But you can check T3-app + Clerk.io integration example. They pass Clerk auth there.
George
George2mo 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
George2mo ago
No description
George
George2mo ago
Then I can use it like this
No description
George
George2mo ago
I am not sure if this is a good approach or not, but it works well