Clerk Auth Provider
Clerk is a user management service which you can use with a self-hosted TinaCMS setup.
Looking for the code? Check out the GitHub repository.
Getting Started
To get started you will need to install the following dependencies:
Setup
Visit clerk.com to create an account and an "application". Once you've done that, navigate to the API Keys tab to find your credentials and store them in the .env file in your project.
Be sure to update TINA_PUBLIC_ALLOWED_EMAIL with the email address you'll use to sign in to Clerk.
Update the dev command
When self-hosting, you may want to disable auth for local development.
Update your TinaCMS Config
Add the following to your tina/config.{ts.js} file. Be sure to replace "my-email@gmail.com" with the email you're signing in with:
Note that we're checking if the signed-in user's email exists in a hardcoded array. There are a few ways to do this in a more maintainable way:
- Create an organization in Clerk, and check to see if the signed-in user is part of the org for this project. Note that organizations are currently limited to 3 users on the free plan.
- Create an "allow-list". Note that this is a paid feature.
Update the TinaCMS Backend
Add the following to your pages/api/tina/[...routes].{ts,js} file