v1.0
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { createTRPCReact } from "@trpc/react-query";
|
||||
import { httpBatchLink } from "@trpc/client";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import superjson from "superjson";
|
||||
import type { AppRouter } from "../../api/router";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export const trpc = createTRPCReact<AppRouter>();
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
const trpcClient = trpc.createClient({
|
||||
links: [
|
||||
httpBatchLink({
|
||||
url: "/api/trpc",
|
||||
transformer: superjson,
|
||||
fetch(input, init) {
|
||||
return globalThis.fetch(input, {
|
||||
...(init ?? {}),
|
||||
credentials: "include",
|
||||
});
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
export function TRPCProvider({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
</QueryClientProvider>
|
||||
</trpc.Provider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user