14 lines
523 B
TypeScript
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 }),
|
|
})
|
|
]
|
|
})
|