tRPCttRPC
Powered by
TuxerT
tRPC•4y ago•
9 replies
Tuxer

query and mutate promise on next

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 */);
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

[Typescript] Client query / mutate has any type
KhojoKKhojo / ❓-help
10mo ago
[Typescript] Client query/mutate has any type
Mr. JokerMMr. Joker / ❓-help
12mo ago
tRPC + Nextjs: redirect on next error with new TanStack Query integration
LopaisLLopais / ❓-help
7mo ago
I can't mutate or query in SvelteKit
🇵🇸 Prince Toast�🇵🇸 Prince Toast / ❓-help
3y ago