🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Using Sanity for user authentication and database management

12 replies
Last updated: Jun 5, 2023
Can I do authentication with Sanity? Where users can register and login? If there are any resources on this please point me to them. I have scoured the documentation, but can't seem to get it.
Jun 5, 2023, 11:03 AM
Are you hoping to for these users to become project member or just use the Content Lake as a database?
If it’s the former, while you can have unlimited users in a project, they would all have Admin access. This wouldn’t be a great idea.

You could use Sanity as a database for your users but there’s nothing built in to manage that for you. That would be something that you would have to create.
Jun 5, 2023, 2:31 PM
Jun 5, 2023, 2:32 PM
I would love to use the Content Lake as database
Jun 5, 2023, 2:32 PM
So I thought I could also use Sanity for the users' database altogether.
Jun 5, 2023, 2:33 PM
Yeah, totally possible. It would require you to use the JS client to create the user documents. You’d also need to make sure you salt and hash any passwords you store and use something like Passport.js.
Jun 5, 2023, 2:39 PM
Okay!Great! Thanks!
Jun 5, 2023, 2:40 PM
But could I use Authentication providers with this too? Like GoogleAuth?
Jun 5, 2023, 2:40 PM
Yeah, any auth provider that you can specify the database for would work.
Jun 5, 2023, 2:41 PM
Jun 5, 2023, 2:41 PM
That's very helpful
Jun 5, 2023, 2:41 PM
Jun 5, 2023, 2:41 PM
You’re welcome!
Jun 5, 2023, 3:00 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?