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:
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:
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.
TinaCMS provides two database adapters in the init workflow: "Redis" (VercelKV) & "MongoDB". Learn more about Database Adapters here.
The init commands does the following:
/tina/[...routes].{ts, js}
to handle TinaCMS GraphQL and auth requeststina/database.{ts, js}
to handle the databaseOnce 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
Last Edited: August 20, 2024
Product
Resources
© TinaCMS 2019–2024