I have this provider
"use client";
import { convex } from "@/lib/convex";
import { ConvexAuthProvider } from "@convex-dev/auth/react";
const ReactConvexProvider = ({ children }: { children: React.ReactNode }) => {
return <ConvexAuthProvider client={convex}>{children}</ConvexAuthProvider>;
};
export default ReactConvexProvider;
and this query
import { api } from "@/convex/_generated/api";
import LandingPage from "@/features/landing-page/landing-page";
import { fetchQuery } from "convex/nextjs";
export default async function HomePage() {
const currentUser = await fetchQuery(api.auth.getCurrentUser);
console.log(currentUser);
return <LandingPage />;
}
import { convexAuth, getAuthUserId } from "@convex-dev/auth/server";
import Google from "@auth/core/providers/google";
import { query } from "./_generated/server";
import { ConvexError } from "convex/values";
export const { auth, signIn, signOut, store } = convexAuth({
providers: [Google],
});
export const getCurrentUser = query(async (ctx) => {
const userId = await getAuthUserId(ctx);
if (!userId) {
return null;
}
const user = await ctx.db.get(userId);
if (!user) {
throw new ConvexError("User not found");
}
return user;
});
I login with but the current user is always null