Accessing Clerk logged in user in Next Server Components
Hello, I just added Clerk to my Nextjs + Convex app, I also followed the guide to store users in tthe convex database (https://docs.convex.dev/auth/database-auth)
The user is being stored in the database correctly, how can I access the logged in user in a server component?
Here is what I've tried:
For some reason, the
user
is always null
Any ideas?2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
you need to pass along the user token in fetchQuery. I think there's some docs on it, maybe in the nextjs section, or you could check out the clerk docs / demo / template