using batching to mitigate startup request cost

This commit is contained in:
2024-11-08 16:53:56 -07:00
parent c47d7405c2
commit cc8d004aa4
5 changed files with 14 additions and 33 deletions

View File

@@ -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,
}),