import { createTRPCProxyClient, createWSClient, wsLink } from "@trpc/client" import superjson from "superjson" import type { AppRouter } from "../backend" const wsUrl = new URL(location.href) wsUrl.protocol = wsUrl.protocol.replace("http", "ws") wsUrl.pathname = "/ws" wsUrl.hash = "" export const trpcClient = createTRPCProxyClient({ links: [ wsLink({ client: createWSClient({ url: wsUrl.href }) }) ], transformer: superjson })