SaraS
Convex Community16mo ago
7 replies
Sara

Github Authentication issue with React Vite

I'm using convex auth with React, and I'm having an issue that hasn't occurred before with next.js

I'm trying to log the user object, but it's returning null, and the functions of store and view don't appeared to be not working as well?
here's some code snippets:
in Main.tsx
import { ConvexReactClient } from "convex/react";
import { ConvexAuthProvider } from "@convex-dev/auth/react";


const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string,);

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <ConvexAuthProvider client={convex}>
      <App />
    </ConvexAuthProvider>
  </StrictMode>,
)


in convex/users:
export const viewer = query({
  args: {},
  handler: async (ctx, args) => {
    const userId = await getAuthUserId(ctx)
    return userId !== null ? await ctx.db.get(userId):null
  },
});

and here are some logs:
I just need to understand what to do here
image.png
Was this page helpful?