Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
TSX
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253"use client";
import type { AppRouter } from "@openstatus/api";import type { QueryClient } from "@tanstack/react-query";import { QueryClientProvider } from "@tanstack/react-query";import { createTRPCClient } from "@trpc/client";import { createTRPCContext } from "@trpc/tanstack-react-query";import { useState } from "react";
import { makeQueryClient } from "@/lib/trpc/query-client";import { endingLink, sentryLoggerLink } from "@/lib/trpc/shared";
export const { TRPCProvider, useTRPC, useTRPCClient } = createTRPCContext<AppRouter>();
let browserQueryClient: QueryClient | undefined = undefined;function getQueryClient() { if (typeof window === "undefined") { // Server: always make a new query client return makeQueryClient(); } // Browser: make a new query client if we don't already have one // This is very important, so we don't re-make a new client if React // suspends during the initial render. This may not be needed if we // have a suspense boundary BELOW the creation of the query client if (!browserQueryClient) browserQueryClient = makeQueryClient(); return browserQueryClient;}
export function TRPCReactProvider({ children }: { children: React.ReactNode }) { const queryClient = getQueryClient(); const [trpcClient] = useState(() => createTRPCClient<AppRouter>({ links: [ sentryLoggerLink(), endingLink({ headers: { "x-trpc-source": "client", }, }), ], }), );
return ( <QueryClientProvider client={queryClient}> <TRPCProvider trpcClient={trpcClient} queryClient={queryClient}> {children} </TRPCProvider> </QueryClientProvider> );}