Web Dev Cody
Web Dev Cody5mo ago

I'm getting null for getUserIdentity

Any clue why I keep getting null for getUserIdentity. Do I maybe just have something misconfigured? I'm using the next.js stuff
"use client";

import { ConvexAuthNextjsProvider } from "@convex-dev/auth/nextjs";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";

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

export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ConvexAuthNextjsProvider client={convex}>
{children}
</ConvexAuthNextjsProvider>
);
}
"use client";

import { ConvexAuthNextjsProvider } from "@convex-dev/auth/nextjs";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";

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

export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<ConvexAuthNextjsProvider client={convex}>
{children}
</ConvexAuthNextjsProvider>
);
}
then I call an action
const generateVideoAction = useAction(api.videos.generateVideoAction);
const generateVideoAction = useAction(api.videos.generateVideoAction);
I'm logged in
export const generateVideoAction = action({
args: {
script: v.string(),
},
async handler(ctx, input) {
console.log(await ctx.auth.getUserIdentity());

export const generateVideoAction = action({
args: {
script: v.string(),
},
async handler(ctx, input) {
console.log(await ctx.auth.getUserIdentity());

this prints null
11 Replies
Michal Srb
Michal Srb5mo ago
Do you have both the server provider and the middleware setup? You need everything from "App Router with SSA" tab: https://labs.convex.dev/auth/setup#set-up-the-react-provider Or you can switch to using the vanilla react provider (shown in the "App Router without SSA" tab)
Set Up Convex Auth - Convex Auth
Authentication library for your Convex backend
Web Dev Cody
Web Dev CodyOP5mo ago
yeah I'm pretty sure I followed that correctly
Michal Srb
Michal Srb5mo ago
And how are you ensuring the client is logged in? If you can share a repo with repro I can have a look.
Web Dev Cody
Web Dev CodyOP5mo ago
what is repro? one sec I'll just make it public
Web Dev Cody
Web Dev CodyOP5mo ago
GitHub
GitHub - webdevcody/scary-story-generator
Contribute to webdevcody/scary-story-generator development by creating an account on GitHub.
Web Dev Cody
Web Dev CodyOP5mo ago
yeah I've gone over my code a few times, I can't see where I misconfigured this
Michal Srb
Michal Srb5mo ago
Repro: “reproduce” or “reproduction” of a bug I shouldn’t shorten 🙂
Kibru
Kibru5mo ago
same issue here. user is logged in, but getUserIdentity() returns null
Michal Srb
Michal Srb5mo ago
I reproduced the issue, looking @Web Dev Cody @Kibru while I'm fixing this please change your next.config.js to:
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
};

export default nextConfig;
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
};

export default nextConfig;
Kibru
Kibru5mo ago
thanks. it works.
Michal Srb
Michal Srb5mo ago
@Web Dev Cody @Kibru please upgrade convex and @convex-dev/auth to latest for the fix

Did you find this page helpful?