I've followed the guide "Usage with Next.js" and now I only have the
useQuery
useQuery
and use
useMutation
useMutation
hooks exposed when I want to call a route. How do I also expose the regular
query
query
and
mutate
mutate
promises on these routes?
Edit: Solution:
const utils = trpc.useContext();// use it (for example in an event handler)const someResult = await utils.client.someRouter.someProcedure.query(/* args maybe */);
const utils = trpc.useContext();// use it (for example in an event handler)const someResult = await utils.client.someRouter.someProcedure.query(/* args maybe */);