Skip to content

Quick Start

Terminal window
ctkit init

This creates:

  • schemas/ — where your content type definitions live
  • migrations/ — where generated migrations are stored
  • ctkit.config.ts — project configuration

Create a .env file in the project root:

.env
CONTENTFUL_MANAGEMENT_TOKEN=CFPAT-xxxxxxxxxxxxx
CONTENTFUL_SPACE_ID=your_space_id
CONTENTFUL_ENVIRONMENT_ID=master

See the Configuration page for details on where to find these values.

Terminal window
ctkit test

This verifies that ctkit can reach your Contentful space. You should see a success message with your space name and environment.

Create a schema file at schemas/blogPost.ts:

schemas/blogPost.ts
import { contentType, fields } from '@ctkit/core';
export const blogPost = contentType('blogPost', {
name: 'Blog Post',
fields: {
title: fields.symbol({
name: 'Title',
required: true,
}),
body: fields.richText({
name: 'Body',
}),
publishedAt: fields.date({
name: 'Published At',
}),
},
});
Terminal window
ctkit push

ctkit diffs your local schemas against the remote content model, generates the necessary migration, and applies it to your Contentful environment.

Terminal window
ctkit check

If your local schemas match the remote content model, you’ll see:

✓ Everything is in sync.

That’s it — your content model is now defined in code and deployed to Contentful.