For SpartaF
Convex Communityβ€’2y agoβ€’
7 replies
For Sparta

ctx.auth.getUserIdentity() is returning undefined

Hey! Just started using Convex so far it's been amazing. I added the Clerk integration and I am also using the latest NextJS version(with app router). I created a query function that is getting some a list from the database. When I call it from the frontend it seems the backend doesn't have the user identity right away.

export const getCurrentUsersLists = query({
  args: {},
  handler: async (ctx, args) => {
    const identity = await ctx?.auth?.getUserIdentity()

    const info = identity?.name
    console.log("πŸš€ ~ handler: ~ info:", info)

    

    return "hello"
  }
})


In this function I need to be able to get lists by the user id but the user is never defined. I have made sure I am logged in too. I have also made sure that I setup my auth.config.js correctly. It seems the mutation function works just fine but the queries do not. Any help would be awesome! Thanks.

Here is what the logs look like. Seems like on load it's undefined and then eventually the data comes.
image.png
Was this page helpful?