How to authenticate my Livekit App using Clerk?
# ask-ai
c
How to authenticate my Livekit App using Clerk?
t
Thanks for reaching out, Sam. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! LiveKit uses JWT-based access tokens for authentication, which are signed with an API key and secret. While Clerk isn’t directly mentioned in the documentation, it can definitely be used as the user authentication layer before issuing LiveKit tokens. Could you please share a bit more about what you’re aiming to do? Are you looking to integrate Clerk to validate users before generating LiveKit tokens, or do you have a specific environment (like web or mobile) or use case in mind? I’m here to help you every step of the way! Sources: Authentication | LiveKit Docs | Web and mobile frontends | LiveKit Docs | TEMPLATE.md | README.md
c
So my users authenticate to my app using Clerk (https://clerk.com/). Clerk has it's own way to authenticate users to validate token etc. How does that work with Livekit which has another token validation process? Should I use both? Should I use only Livekit?
t
I'm glad you're looking to integrate Clerk with LiveKit! Here's a friendly two-step authentication process that can help you get started: 1. First, authenticate your users with Clerk to confirm their identity. 2. Then, generate LiveKit tokens for those authenticated users through your backend server. LiveKit uses JWT-based tokens for authentication, which are securely signed with your API key and secret. Once a user is authenticated via Clerk, your backend can create a LiveKit token with the right permissions—like joining rooms or publishing tracks—and send it back to the client. Here’s a simple overview of how it works: 1. Authenticate the user with Clerk on the client side. 2. Send the authenticated user’s identity to your backend. 3. Your backend verifies the user’s identity using Clerk’s API. 4. Generate a LiveKit token using the LiveKit server SDK and return it to the client. This method lets you smoothly combine Clerk’s user authentication with LiveKit’s token-based access control. If you'd like, I’m here to help you with any specific parts—whether it’s setting up the backend token generation or figuring out user permissions in LiveKit. Just let me know! Sources: Flutter SDK | livekit/livekit_composite | DeepWiki | Web and mobile frontends | LiveKit Docs | avatars/tavus/voice-assistant-frontend/app/api/connection-details/route.ts
c
ok thanks, that helps!