Custom Hooks using tRPC API

I want to create a custom hook with the function I created in tRPC routes. getUserDetails: privateProcedure.query(async ({ c, ctx }) => { const user = await db.user.findFirst({ where: { email: ctx.user.email, }, }); if (!user) { return c.json({ message: "User not found", success: false, data: null, code: NOT_FOUND, }); } return c.json({ message: "User found", success: true, data: user, code: OK, }); }), i want to create use-user.ts custom hook but I dont know how to use tRPC API, I'm using tRPC v11. Can someone help me on this.
No description
3 Replies
OreQr
OreQr2w ago
Hi @Vishnu Mouli, what lib are you using with trpc that you doing c.json(... ?
Vishnu Mouli
Vishnu MouliOP2w ago
Sorry that was hono js, earlier i was using jstack and shifted to trpc

Did you find this page helpful?