NazCodelandN
tRPC3y ago
6 replies
NazCodeland

merging other routers to appRouter

Hey everyone, I am using the https://icflorescu.github.io/trpc-sveltekit package in my SvelteKit project. My question is not related to that package (at least I don't think it is) I figured I mention it since it might be related and I just don't know...

I am wondering if I have this code,
// router/router.ts
import type { Context } from '$server/trpc/context';
import { initTRPC } from '@trpc/server';

export const tRPC = initTRPC.context<Context>().create();

export const publicProcedure = tRPC.procedure;
export const appRouter = tRPC.router;

export type AppRouter = typeof appRouter;


and say I also have
// routers/user.ts
import { appRouter, publicProcedure } from '$server/trpc/router';

export const userRouter = appRouter({
    list: publicProcedure.query(() => {
        return [];
    })
});


am I able to merge the userRouter onto the appRouter directly within the /router/user.ts file?
Was this page helpful?