Set up NotCMS in your project and start fetching content from Notion in minutes.

Prerequisites

Before you begin, make sure you have:
  • Node.js 12 or higher installed
  • A Notion account with at least one database
  • Basic knowledge of TypeScript (recommended)

Step 1: Install NotCMS

npm install notcms

Step 2: Initialize Your Project

Use the NotCMS CLI to set up your project:
npx notcms-kit init
This command will:
  1. Check environment variables
  2. Create a notcms.config.json configuration file

Step 3: Configure Environment Variables

Add your NotCMS credentials to your .env file:
NOTCMS_SECRET_KEY=your-secret-key
NOTCMS_WORKSPACE_ID=your-workspace-id
Get your credentials from the NotCMS Dashboard

Step 4: Pull Your Schema

Generate TypeScript types from your Notion databases:
npx notcms-kit pull
This creates a type-safe schema file at src/notcms/schema.ts:
export const schema = {
  blog: {
    id: "abc123...",
    properties: {
      title: "title",
      published: "checkbox",
      author: "rich_text",
      tags: "multi_select"
    }
  }
} satisfies Schema;

Step 5: Start Using NotCMS

Create a client and start querying your content:
import { Client } from 'notcms';
import { schema } from './notcms/schema';

const nc = new Client({ schema });

// Fetch all published blog posts
const [posts, error] = await nc.query.blog.list();

if (error) {
  console.error("Failed to fetch posts:", error);
} else {
  posts.forEach(post => {
    console.log(post.title);
  });
}

What’s Next?

Common Issues