mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
using batching to mitigate startup request cost
This commit is contained in:
@@ -4,24 +4,19 @@ import superjson from "superjson";
|
||||
import { httpBatchLink, httpLink } from "@trpc/client";
|
||||
import { trpc } from "./utils";
|
||||
import { getQueryClient } from "@/app/providersQueryClientUtils";
|
||||
import { isServer } from "@tanstack/react-query";
|
||||
|
||||
export default function TrpcProvider({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
// NOTE: Your production URL environment variable may be different
|
||||
const url = "http://localhost:3000/api/trpc/"
|
||||
//"/api/trpc";
|
||||
// process.env.NEXT_PUBLIC_APP_DOMAIN &&
|
||||
// !process.env.NEXT_PUBLIC_APP_DOMAIN.includes("localhost")
|
||||
// ? `https://www.${process.env.NEXT_PUBLIC_APP_DOMAIN}/api/trpc/`
|
||||
// : "http://localhost:3000/api/trpc/";
|
||||
const url = isServer ? "http://localhost:3000/api/trpc/" : "/api/trpc"
|
||||
|
||||
const [trpcClient] = useState(() =>
|
||||
trpc.createClient({
|
||||
links: [
|
||||
httpLink({
|
||||
httpBatchLink({
|
||||
url,
|
||||
transformer: superjson,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user