mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
moving v2 to top level
This commit is contained in:
33
src/services/serverFunctions/TrpcProvider.tsx
Normal file
33
src/services/serverFunctions/TrpcProvider.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
"use client";
|
||||
import { useState } from "react";
|
||||
import superjson from "superjson";
|
||||
import { httpBatchLink } from "@trpc/client";
|
||||
import { trpc } from "./trpcClient";
|
||||
import { getQueryClient } from "@/app/providersQueryClientUtils";
|
||||
import { isServer } from "@tanstack/react-query";
|
||||
|
||||
export default function TrpcProvider({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const url = isServer ? "http://localhost:3000/api/trpc/" : "/api/trpc";
|
||||
|
||||
const [trpcClient] = useState(() =>
|
||||
trpc.createClient({
|
||||
links: [
|
||||
httpBatchLink({
|
||||
url,
|
||||
transformer: superjson,
|
||||
maxURLLength: 10_000, // limit number of batched requests
|
||||
}),
|
||||
],
|
||||
})
|
||||
);
|
||||
|
||||
return (
|
||||
<trpc.Provider client={trpcClient} queryClient={getQueryClient()}>
|
||||
{children}
|
||||
</trpc.Provider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user