Varich
Varich3y ago

Mutation with react-hook-form

Hello I'm trying to use mutation with react-hook-form. In the form, I will have to give interface of the input that I want, so I'm wondering whether it's possible to get the type of input to some mutation from trpc and pass it as input type.
3 Replies
sachin
sachin3y ago
no you can't, you'll have to export the Zod input schema separately and import that on the client
sachin
sachin3y ago
actually if you just want the input type, you can use this: https://trpc.io/docs/v10/infer-types
Inferring Types | tRPC
It is often useful to wrap functionality of your @trpc/client or @trpc/react-query api within other functions. For this purpose, it's necessary to be able to infer input types and output types generated by your @trpc/server router.
sachin
sachin3y ago
If you want the actual Zod schema take a look at this: https://kitchen-sink.trpc.io/react-hook-form