Igor Kotua
Igor Kotua
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
I will try to wrap this in Authenticated or prevent query from running if useConvexAuth returns {isAuthenticated: false}
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
Oh ok, that's a bit confusing. I thought ConvexProviderWithClerk is taking care of this
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
Basically this, nothing special "use client"; import { useQuery } from "convex/react"; import { api } from "../../../convex/_generated/api"; import { useConvexAuth } from "convex/react"; export default function Page({ params }: { params: { id: string } }) { const auth = useConvexAuth(); const data = useQuery(api.videos.getVideo, { videoId: params.id as any }); return ( <div> <h1>Video</h1> {JSON.stringify(data?.description)} {JSON.stringify(auth)} </div> ); }
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
@Michal Srb well my client is authenticated, useConvexAuth hooks confirms that. But my convex query still returns null from getUserIdentity
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
Let me know if you need more info 🙂
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
Also getConvexAuth on this page returns authenticated: true
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
"use client";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";
import { ConvexProviderWithClerk } from "convex/react-clerk";
// import { ClerkProvider } from "@clerk/nextjs";
// import { useAuth } from "@clerk/nextjs";
import { useUser, ClerkProvider, useAuth } from "@clerk/clerk-react";
import { useConvexAuth } from "convex/react";
import { useEffect, useState } from "react";
import { useMutation } from "convex/react";
import { api } from "../../convex/_generated/api";
import { Id } from "../../convex/_generated/dataModel";

const convexClient = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ClerkProvider
publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY!}
>
<ConvexProviderWithClerk client={convexClient} useAuth={useAuth}>
{children}
</ConvexProviderWithClerk>
</ClerkProvider>
);
}
"use client";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";
import { ConvexProviderWithClerk } from "convex/react-clerk";
// import { ClerkProvider } from "@clerk/nextjs";
// import { useAuth } from "@clerk/nextjs";
import { useUser, ClerkProvider, useAuth } from "@clerk/clerk-react";
import { useConvexAuth } from "convex/react";
import { useEffect, useState } from "react";
import { useMutation } from "convex/react";
import { api } from "../../convex/_generated/api";
import { Id } from "../../convex/_generated/dataModel";

const convexClient = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ClerkProvider
publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY!}
>
<ConvexProviderWithClerk client={convexClient} useAuth={useAuth}>
{children}
</ConvexProviderWithClerk>
</ClerkProvider>
);
}
15 replies
CCConvex Community
Created by Igor Kotua on 2/19/2024 in #support-community
Issues with getUserIdentity inside queries (auth with Clerk)
This is my client setup
15 replies