NazCodeland
NazCodeland14mo ago

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({...})
export const router = t.router({...})
to
export const appRouter = t.router({...})
export const appRouter = t.router({...})
and then at the bottom
export type Router = typeof router;
export type Router = typeof router;
changed to
export type Router = typeof appRouter;
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';
import type { Router } from '$lib/trpc/router';
to
import type { Router } from '$lib/trpc/appRouter';
import type { Router } from '$lib/trpc/appRouter';
inside of /src/hooks.server.ts I've changed the import
import { router } from '$lib/trpc/router';
import { router } from '$lib/trpc/router';
to
import { appRouter } from '$lib/trpc/appRouter';
import { appRouter } from '$lib/trpc/appRouter';
and changed this line
export const handle: Handle = createTRPCHandle({
appRouter,
createContext,
export const handle: Handle = createTRPCHandle({
appRouter,
createContext,
to
export const handle: Handle = createTRPCHandle({
router,
createContext,
export const handle: Handle = createTRPCHandle({
router,
createContext,
tRPC-SvelteKit
Getting started | tRPC-SvelteKit
Get started with tRPC-SvelteKit
2 Replies
Nick
Nick14mo ago
But what's the error?
NazCodeland
NazCodeland14mo ago
sorry for the late response just seeing this, I managed to fix it, in my hooks.server.ts(I'm using Svelte/SvelteKit) I had
export const handle: Handle = createTRPCHandle({
appRouter,
createContext
});
export const handle: Handle = createTRPCHandle({
appRouter,
createContext
});
instead of
export const handle: Handle = createTRPCHandle({
router: appRouter,
createContext
});
export const handle: Handle = createTRPCHandle({
router: appRouter,
createContext
});
My typescript wasn't working properly so that wasn't even throwing a warning, but since fixing my typescript I noticed it