"use client"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import React, { useState } from "react"; import { api } from "./trpc"; import { loggerLink } from "@trpc/client"; import { httpBatchLink } from "@trpc/client"; import superjson from "superjson"; export default function Providers({ children }: { children: React.ReactNode }) { const [queryClient] = React.useState(() => new QueryClient()); const [trpcClient] = useState(() => api.createClient({ links: [ loggerLink({ enabled: (op) => process.env.NODE_ENV === "development" || (op.direction === "down" && op.result instanceof Error), }), httpBatchLink({ // TODO: Change this to be a full URL exposed as a client side setting url: `/api/trpc`, transformer: superjson, }), ], }), ); return ( {children} ); }