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
You can pass any data to context and then access it in procedure
Do you know of any examples of doing this?
I'm doing this 🙂
But you can check T3-app + Clerk.io integration example. They pass Clerk auth there.
Yeh I was able to do this, by creating a function that accepts an array of user permissions and returns a trpc middleware:
Then I can use it like this
I am not sure if this is a good approach or not, but it works well