Nohac
Nohac
TTCTheo's Typesafe Cult
Created by Nohac on 3/13/2024 in #questions
Call trpc without using reactQuery/hook in a "use client" async function
I know how to call trpc from a server component and a client component by importing api from trpc/server or trpc/react respectively. My problem is that I see no easy way to do something like this in for example a callback:
const greeting = await api.post.hello.query({ text: "hello" });
const greeting = await api.post.hello.query({ text: "hello" });
That works fine in a server component, but in a client component, it requires me to use useQuery. Any suggestion for how I can enable this?
1 replies