How to handle JWT authentication and authorization in Sanity CMS?

13 replies
Last updated: Nov 29, 2025
Hi all, I hope you have had a great day.I'm new to sanity and I'd like to ask a question that might sound silly.
I have a react application where my users log in to access some data, is it possible to handle my form authentication & authorization (jwt) using sanity or other backend programming languages like node.js and MongoDB are required to do so?
AI Update

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:

  1. Sanity Studio users - These are content editors and administrators who access the Sanity Studio to manage content. Sanity handles authentication for these users.

  2. 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:

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).

Show original thread
13 replies

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.

Was this answer helpful?