How do I use a tRPC procedure outside a react component
Hello guys, I made a simple router which will give me similar tags from my tags model from prisma
However the part where I want to call this code is outside of a react component and as its a hook I cannot call it outside a react component. I tried searching the web and I found out that to do that I will need to expose it using next API endpoint. There must be a better way to do this please let me know if you know any.
Here is the image where I want to call it, in case you want the extra info
2 Replies
if this code is running client side, your best bet is using the vanilla client https://trpc.io/docs/client/introduction
tRPC Client | tRPC
The "vanilla" tRPC client can be used to call your API procedures as if they are local functions, enabling a seamless development experience.
Thank you very much for replying cje, I will try it and let you know