sendou.ink/utils/trpc.ts
Alex Johansson edcf1c875a
suggested changes for trpc 5 (#357)
* suggested changes for trpc 5

* prettier format

* add queryclient options

* 5.0

Co-authored-by: Kalle (Sendou) <38327916+Sendouc@users.noreply.github.com>
2021-04-06 20:48:30 +03:00

17 lines
564 B
TypeScript

import { createReactQueryHooks, createTRPCClient } from "@trpc/react";
import superjson from "superjson";
// Type-only import:
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
import type { AppRouter } from "../pages/api/trpc/[trpc]";
// create helper methods for queries, mutations, and subscriptionos
export const client = createTRPCClient<AppRouter>({
url: "/api/trpc",
transformer: superjson,
});
// create react query hooks for trpc
export const trpc = createReactQueryHooks({
client,
});