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