Tina Docs
Introduction
Overview
Introduction To TinaCMS
Getting Started
Using the Tina Editor
FAQ
Core Concepts
Content Modeling
Data Fetching
Visual Editing
Querying Content
Overview
Writing custom queries
Editing
Overview
Markdown & MDX
Block-based editing
Single Document Collections
Customizing Tina
Overview
Validation
Custom Field Components
Custom List Rendering
Format and Parse Input
Filename Customization
Before Submit function
Going To Production
Overview
Tina Cloud
Self-Hosted
Introduction
Getting Started
Deploy a (Next.js) Example Site
CLI Quick Start on an Existing site (Next.js only)
Manual Setup (Agnostic)
Migrating From Tina Cloud
Querying Content
User Management
Drafts
Overview
Draft Fields
Editorial Workflow
Guides
Overview
Framework Guides
Separate Content Repo
Querying Tina Content at Runtime
Internationalization
Migrating From Forestry
Further Reference
Overview
Config
Schema
The "tina" folder
The TinaCMS CLI
Media
Search
Content API
Tina's edit state
The "tinaField" helper
Self-Hosted Components

If you want to self-host the Tina backend, and don't want to use our pre-configured starter, you can follow the steps below.

We offer a CLI init to quickly setup the backend on Next.js sites, or you can take the manual setup approach if you're using another framework.

Prefer a video walkthrough? Check out this video:

Setup

If you already have Tina Setup in your project, make sure has the latest version of all tina packages.

In the terminal, run:

npx @tinacms/cli@latest init backend

This will set up TinaCMS (if it's not already installed) and add the backend pieces required for self-hosting.

This will prompt you to answer some questions:

GitHub Personal Access Token

A Github Personal Access Token can be created in the GitHub account settings.

Make sure to assign it repo access to your new repository with Read/Write access to Contents.

Choosing a Database Adapter

TinaCMS provides two database adapters in the init workflow: "Redis" (VercelKV) & "MongoDB". Learn more about Database Adapters here.

What The Init Command Does

The init commands does the following:

  • Sets up pages/tina/[...routes].{ts, js} to handle TinaCMS GraphQL and auth requests
  • Sets up tina/database.{ts, js} to handle the database
    • Configures the GitHub Git provider
    • Configures the database adapter
  • Configures the TinaCMS Auth.js auth provider
  • Installs any dependencies needed for the chosen Git provider, database adapter, and authentication provider

After the init command

Once the init command finishes make sure to copy the environment variables that are printed in the terminal. You will also need to add these to your hosting provider.

Update all backend data fetching to use the new database client

-import client from '../tina/__generated__/client'
+import client from '../tina/__generated__/databaseClient'

Check out the this page for more information.

After these steps are completed the dev and build commands should be ready for use

Next Steps

  • If you want to change your Git provider, database adapter, or authentication provider, check out the reference.
  • Got questions? Feel ask in our Discord

Last Edited: August 20, 2024

Previous
Using the Next.js Vercel Example
Next
Self Hosted Manual Setup

Product

Showcase
TinaCloud
Introduction
How Tina Works
Roadmap

Resources

Blog
Examples
Support
Media

Whats New
TinaCMS
TinaCloud
Use Cases
Agencies
Documentation
Teams
Jamstack CMS
Benefits
MDX
Markdown
Git
Editorial Workflow
Customization
SEO
Comparisons
TinaCMS vs Storyblok
TinaCMS vs Sanity
TinaCMS vs DecapCMS
TinaCMS vs Contentful
TinaCMS vs Builder.io
TinaCMS vs Strapi
Integrations
Astro
Hugo
NextJS
Jekyll