Home
Blog
Showcase
Community
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
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
Overview
Running the Local GraphQL API
Querying the API
Using Curl & Fetch
Data Layer
Tina's edit state
The "tinaField" helper
Self-Hosted Components

The TinaCMS CLI can be used to set up your project with a TinaCMS schema configuration, and run a local version of the TinaCMS GraphQL API (using your filesystem's content). For a real-world example of how this is being used checkout the TinaCloud Starter.

Installation

The @tinacms/cli package will be installed as a dev dependency with the tina init command.

npx @tinacms/cli init

This will setup a dummy tina/config.{js,ts} in your site, and install any required Tina dependencies.

Running the GraphQL API

tinacms dev will compile the schema into static files, generate typescript types for you to use in your project, and start a GraphQL server on http://localhost:4001

This command also takes an argument (-c) that allows you to run a command as a child process. This is very helpful for running a dev server and building your next.js app. The scripts portion of your package.json should look like this.

"scripts": {
"dev": "tinacms dev -c \"next dev\"",
"build": "tinacms build && next build",
"start": "tinacms build && next start",
...
},

The reason we want to run the GraphQL API with our site is so that:

  • When our static pages build in CI, they can source their content from the local files using the GraphQL API.
  • In development, we can test out Tina with our local files.

Now if you run the updated dev script with:

npm run dev

or

yarn dev

Your live site will run, but so will a local version of the GraphQL Content API.

Your console might show something like:

> yarn dev
Started Filesystem GraphQL server on port: 4001
Visit the playground at http://localhost:3000/admin/index.html#/graphql
Generating Tina config
...

Once the graphql server is running, you can start to explore your graphQL content through the Altair client at http://localhost:3000/admin/index.html#/graphql

Altair client

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