Leonardo Rocchini
Leonardo Rocchini

Reputation: 31

Issue with Clerk auth() helper

I have a issue with Clerk auth() helper (auth() doc) with react and next 13 (app router). When attempting to retrieve both the userId and user from auth() const { userId, user } = auth(); , I observe that the userId holds a valid value containing the user's ID. However, I encounter an issue with user, as it appears to be undefined.

Upvotes: 2

Views: 1093

Answers (1)

user_3891
user_3891

Reputation: 11

Just came across the same problem, the following worked for me.

const { userId } = auth();
const user = await currentUser();
const email = user?.emailAddresses[0].emailAddress

Upvotes: 1

Related Questions