Json 👺
Json 👺2w ago

Exposing server-side caller and tRPC caller/helper through the same export?

Hey there 👋 I'm wondering if anyone thinks it could be unwise to expose the server-side caller and the tRPC caller through the same export.
// server.ts
import "server-only";
// ...
const caller = createCaller(createContext);

export const getQueryClient = cache(createQueryClient);

const helpers = createTRPCOptionsProxy({
ctx: createContext,
router: appRouter,
queryClient: getQueryClient,
});

export const api = {
caller,
helpers,
};
// server.ts
import "server-only";
// ...
const caller = createCaller(createContext);

export const getQueryClient = cache(createQueryClient);

const helpers = createTRPCOptionsProxy({
ctx: createContext,
router: appRouter,
queryClient: getQueryClient,
});

export const api = {
caller,
helpers,
};
I would prefer to use both through a single export, but I'm unsure if could be bad practice. Any thoughts are appreciated.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?