Is there a way to use useQuery in server actions?

My aim here is to get all of the properties that useQuery (via trpc) provides - loading, error, onSuccess for mutations, etc - returned from my server action so that I can reflect that in UI updates.

I'm not entirely sure what the difference in use is between next server actions and trpc's server-side api, to be honest. They seem to have a lot of overlap

This is my server action:

"use server";

import { api } from "~/trpc/server";

export async function createNewGrid(id: string) {
  return api.grids.create(id);
}


Is there a way I can get those useful properties from useQuery where I implement this? Also, as this is happening in a client component (I need state and localStorage), is there any value to making this a server action?
Was this page helpful?