aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared-react/providers
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2026-02-01 12:29:54 +0000
committerGitHub <noreply@github.com>2026-02-01 12:29:54 +0000
commit65f6e83f11c82b0ec762e11f3392a80e614ee69a (patch)
tree945d8d73122f07fe6a77c2bd3ac9db566939ba3b /packages/shared-react/providers
parente516a525bca6f319a2f003e9677624e968b277bf (diff)
downloadkarakeep-65f6e83f11c82b0ec762e11f3392a80e614ee69a.tar.zst
refactor: migrate trpc to the new react query integration mode (#2438)
* refactor: migrate trpc to the new react query integration mode * more fixes * more migrations * upgrade trpc client
Diffstat (limited to 'packages/shared-react/providers')
-rw-r--r--packages/shared-react/providers/trpc-provider.tsx18
1 files changed, 11 insertions, 7 deletions
diff --git a/packages/shared-react/providers/trpc-provider.tsx b/packages/shared-react/providers/trpc-provider.tsx
index 696bf195..2c41aa11 100644
--- a/packages/shared-react/providers/trpc-provider.tsx
+++ b/packages/shared-react/providers/trpc-provider.tsx
@@ -1,9 +1,11 @@
import { useMemo } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { httpBatchLink } from "@trpc/client";
+import { createTRPCClient, httpBatchLink } from "@trpc/client";
import superjson from "superjson";
-import { api } from "../trpc";
+import type { AppRouter } from "@karakeep/trpc/routers/_app";
+
+import { TRPCProvider } from "../trpc";
interface Settings {
apiKey?: string;
@@ -12,7 +14,7 @@ interface Settings {
}
function getTRPCClient(settings: Settings) {
- return api.createClient({
+ return createTRPCClient<AppRouter>({
links: [
httpBatchLink({
url: `${settings.address}/api/trpc`,
@@ -31,7 +33,7 @@ function getTRPCClient(settings: Settings) {
});
}
-export function TRPCProvider({
+export function TRPCSettingsProvider({
settings,
children,
}: {
@@ -42,8 +44,10 @@ export function TRPCProvider({
const trpcClient = useMemo(() => getTRPCClient(settings), [settings]);
return (
- <api.Provider client={trpcClient} queryClient={queryClient}>
- <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
- </api.Provider>
+ <QueryClientProvider client={queryClient}>
+ <TRPCProvider trpcClient={trpcClient} queryClient={queryClient}>
+ {children}
+ </TRPCProvider>
+ </QueryClientProvider>
);
}