Add Better Auth admin authentication
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
||||
import { ConvexBetterAuthProvider } from "@convex-dev/better-auth/react";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
|
||||
const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL;
|
||||
|
||||
if (!convexUrl) {
|
||||
@@ -11,6 +14,20 @@ if (!convexUrl) {
|
||||
|
||||
const convex = new ConvexReactClient(convexUrl);
|
||||
|
||||
export function ConvexClientProvider({ children }: { children: ReactNode }) {
|
||||
return <ConvexProvider client={convex}>{children}</ConvexProvider>;
|
||||
export function ConvexClientProvider({
|
||||
children,
|
||||
initialToken,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
initialToken?: string | null;
|
||||
}) {
|
||||
return (
|
||||
<ConvexBetterAuthProvider
|
||||
client={convex}
|
||||
authClient={authClient}
|
||||
initialToken={initialToken}
|
||||
>
|
||||
<ConvexProvider client={convex}>{children}</ConvexProvider>
|
||||
</ConvexBetterAuthProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user