trpc hook pattern. This works, but I’m not convinced…

I want to call my route when a button is clicked and have access to isLoading, onError etc… I have implemented a pattern using ‘’refetch()’’ but it doesn’t feel ‘correct’ is there a better way of doing this. I will also create a custom hook out of it.

const { refetch } = trpc.authDomain.signIn.useQuery(
{ email: userEmail },
enabled: false,
onError: (e: any) => {
console.log('there was an error with the endpoint');

async function isEmailVerified() {
const response = await refetch();
const verification =;

// i want to access isLoading directly without writing many lines of new code which i would have to with this current approach

if (verification?.status === 'tryAgain') {
console.log('email not verified');

if (verification?.status === 'ok') {
console.log('user can now verify code sent to their email address');

Return <button onClick={isEmailVerified}/>

UUUnknown User12/11/2022
2 Messages Not Public
Sign In & Join Server To View
there are no implementation differences between query and mutation according to the docs, its just semantics. Also by definition it’s a query, because its checking if the database exists in the database only.
I think i was wrong on this part, and you are right.
@Ayo even though there is no difference in mutation/query in trpc, thereis a big difference between mutations and query in react query which is what you’re using here
Thank you! This helped my understanding