level-up/frontend/trpc.ts
2025-04-11 21:03:18 +02:00

14 lines
523 B
TypeScript

import { createTRPCClient, httpLink, httpSubscriptionLink, loggerLink, splitLink } from "@trpc/client"
import superjson from "superjson"
import type { AppRouter } from "../backend"
export const trpcClient = createTRPCClient<AppRouter>({
links: [
loggerLink(),
splitLink({
condition: op => op.type === "subscription",
true: httpSubscriptionLink({ url: "/trpc", transformer: superjson }),
false: httpLink({ url: "/trpc", transformer: superjson }),
})
]
})