NazCodelandN
tRPC3y ago
3 replies
NazCodeland

if I export 'appRouter' instead of 'router' I get error

hey everyone, I have this exact setup https://icflorescu.github.io/trpc-sveltekit/getting-started
I created all the files inside of
/src/trpc/
besides the
hooks.server.ts
which is inside
/src/trpc/


only difference is that inside the file
router.ts
I've changed the variable name
router
in this line:
export const router = t.router({...})
to
export const appRouter = t.router({...})
and then at the bottom
export type Router = typeof router;
changed to
export type Router = typeof appRouter;


and changed the file
/src/trpc/router.ts
to
/src/trpc/appRouter.ts
and inside of
/src/trpc/client.ts
changed
import type { Router } from '$lib/trpc/router';
to
import type { Router } from '$lib/trpc/appRouter';


inside of
/src/hooks.server.ts
I've changed the import
import { router } from '$lib/trpc/router';
to
import { appRouter } from '$lib/trpc/appRouter';
and changed this line
export const handle: Handle = createTRPCHandle({
    appRouter,
    createContext,

to
export const handle: Handle = createTRPCHandle({
    router,
    createContext,
tRPC-SvelteKit
Get started with tRPC-SvelteKit
Getting started | tRPC-SvelteKit
Was this page helpful?