Using third-party auth services for user authentication with Sanity.io
Not a silly question at all! This is a common point of confusion for folks new to Sanity.
The short answer: Sanity does not provide end-user authentication for your front-end application users. You'll need to use a third-party authentication service for handling JWT authentication and authorization for your React app users.
Here's what you need to understand:
Two types of "users" in Sanity:
Sanity Studio users - These are content editors and administrators who access the Sanity Studio to manage content. Sanity handles authentication for these users.
Your application's end users - These are the people logging into your React app to access data. Sanity does not handle authentication for these users.
What you should use instead:
For end-user authentication with JWT, you'll want to integrate a third-party auth service like:
- Auth0
- Firebase Authentication
- Supabase Auth
- Magic.link (passwordless)
- Clerk
- NextAuth.js (if using Next.js)
How it works together:
Once you have your auth system in place, you can:
- Authenticate users with your chosen auth provider
- Generate and validate JWTs through that service
- Use those authenticated sessions to control access to your Sanity content
- Optionally, give authenticated users write access to Sanity for features like comments or user-generated content
Can you technically store user data in Sanity? Yes, but it's strongly not recommended for sensitive authentication data. Sanity is built for content publishing and sharing, not as a secure authentication system. Keep your user credentials, passwords, and sensitive auth data in dedicated authentication services.
Think of it this way: Use Sanity for your content (articles, products, etc.) and a dedicated auth service for your users (login, permissions, sessions).
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.