forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproviders-wrapper.tsx
More file actions
32 lines (27 loc) · 868 Bytes
/
Copy pathproviders-wrapper.tsx
File metadata and controls
32 lines (27 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use client";
import React, { Suspense } from "react";
import { PostHogProvider } from "@/lib/providers/posthog-provider";
import { ClerkProvider } from "@clerk/clerk-react";
import { ScarfPixel } from "./scarf-pixel";
import { useRB2B } from "@/lib/hooks/use-rb2b";
import { useGoogleAnalytics } from "../hooks/use-google-analytics";
export function ProvidersWrapper({ children }: { children: React.ReactNode }) {
const clerkPublishableKey = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY;
useRB2B();
useGoogleAnalytics();
const toRender = (
<Suspense fallback={null}>
<PostHogProvider>{children}</PostHogProvider>
<ScarfPixel />
</Suspense>
);
if (clerkPublishableKey) {
return (
<ClerkProvider publishableKey={clerkPublishableKey}>
{toRender}
</ClerkProvider>
);
} else {
return toRender;
}
}