Using Vercel KV & NextAuth to Self-host TinaCMS

June 30, 2023

By Kelly Davis

Earlier this year, we released the first iteration of self-hosted TinaCMS. The initial demo relied on Tina Cloud for auth and used MongoDB for the data layer. That was the first step in helping our users avoid vendor lock-in.

Since then, we've been hard at work on improving our self-hosted offering to make it easier to get started and less dependent on other vendor services (including our own). Today we are excited to share the next iteration of our Tina self-hosted demo site, leveraging Vercel KV for the data layer and NextAuth.js for auth. It is now possible to set up an open-source Next.js & TinaCMS site only relying on GitHub and Vercel.

What is Vercel KV?

Vercel KV is a durable Redis database that enables you to store and retrieve JSON data and is available on both hobby (free) and paid plans. The service is provided in partnership with Upstash and does not require a separate Upstash account. Because of its flexibility and performance, Vercel KV is a great fit for powering the self-hosted TinaCMS data layer.

Using Vercel KV in the TinaCMS data layer

When you build your site with TinaCMS, the ultimate source of truth for your content is your Markdown files. However, features like search and filtering content require a data layer on top of those Markdown files. Virtually any database can be adapted for use with TinaCMS. To enable Vercel KV data layer, we have implemented a new Upstash Redis LevelDB implementation. This provides all the data functionality needed by TinaCMS entirely within the Vercel ecosystem.

Using NextAuth.js in TinaCMS

Tina Cloud provides user & role management, but TinaCMS also supports custom auth solutions that can be adapted for a wide variety of situations. The latest iteration of the Tina self-hosted demo site takes this a step further by integrating with NextAuth.js. By leveraging NextAuth.js, any of the available auth providers (e.g Github, Twitter, Google, etc...) can easily be integrated with TinaCMS. It also features customizable login screens, allowing your site to be fully branded. Lastly, the Tina self-hosted demo site provides a simple auth provider that leverages the same Vercel KV store to immediately enable auth without any additional configuration.

Future Plans

Repo-based media is not currently available for self-hosted TinaCMS. We currently recommend one of our other media manager solutions when self-hosting, such as Cloudinary, AWS S3 or Digital Oceans. This is something that we are exploring and hope to make available. Additionally our new search capability currently requires Tina Cloud but is something we expect to add soon to self-hosting.

Getting Started

Visit the self-hosted demo repo and click the Deploy button to launch the demo on Vercel.

Last Edited: July 12, 2023

Stay in touch 👉