tRPCttRPC
Powered by
NazCodelandN
tRPC•3y 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/
/src/trpc/
besides the
hooks.server.ts
hooks.server.ts
which is inside
/src/trpc/
/src/trpc/


only difference is that inside the file
router.ts
router.ts
I've changed the variable name
router
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
/src/trpc/router.ts
to
/src/trpc/appRouter.ts
/src/trpc/appRouter.ts
and inside of
/src/trpc/client.ts
/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
/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
Getting started | tRPC-SvelteKit
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

errorFormatter ignored when using appRouter.createCaller
seN49SseN49 / ❓-help
3y ago
export full declaration of AppRouter for use in another project
MikeyBMMikeyB / ❓-help
8mo ago
TS error regarding inferred type of 'appRouter'
James HopgoodJJames Hopgood / ❓-help
5mo ago
Error on NextJs AppRouter
sudoSsudo / ❓-help
2y ago