Skip to content
qqpannPublic

About

NotCMS makes it easy to create a headless CMS, from Notion

Topics

Resources

Contributing

Stars

19 stars

Watchers

1 watching

Forks

Repository files navigation

NotCMS logo

NotCMS

Documentation ·

Website · Dashboard · Templates · Blog

NotCMS makes it easy to create a CMS, from Notion. It provides a type-safe TypeScript SDK to interact with Notion databases as your content backend.

npm package Downloads Issues Ask DeepWiki

English | 日本語

Key Features

  • 🛡️ Type Safety: Fully typed queries and responses using TypeScript
  • 🎯 Simple API: Clean and intuitive API for fetching content
  • 📝 Notion as Backend: Use Notion's user-friendly editor for content creation
  • 🔄 Framework Agnostic: Works with any JavaScript framework (Next.js, React, Vue, etc.)
  • 🛠️ CLI Tools: Includes the NotCMS CLI for project setup, browser login, and schema management

Getting Started

Installation

npm install notcms

The CLI is included in notcms; no separate CLI package is required. Replace deprecated npx notcms-kit <command> usage with npx notcms <command>.

Usage

1. Initialize a Project

Run the CLI directly with npx:

npx notcms init

This creates notcms.config.json. If credentials are missing, it opens browser login and saves NOTCMS_SECRET_KEY and NOTCMS_WORKSPACE_ID to .env.local. It ensures notcms is both a direct dependency and available to the project, offering either the detected package manager's install command or an add command without replacing an existing dependency spec. It then pulls the schema and prints a runnable first query example.

2. Refresh Your Schema

Run the standalone pull command whenever your Notion database schema changes:

npx notcms pull

This fetches your database schema from NotCMS and regenerates the configured TypeScript file.

For reference, the generated schema will look something like this:

// src/notcms/schema.ts
import { Client } from "notcms";
import type { Schema } from "notcms";

export const schema = {
  blog: {
    id: "your_notion_database_id",
    properties: {
      title: "title",
      description: "rich_text",
      published: "checkbox",
      thumbnails: "files",
      // Run notcms pull again when properties are updated
    },
  },
} satisfies Schema;

export const nc = new Client({ schema });

3. Query Your Content

import { nc } from "./notcms/schema";

// List all blog posts
const [pages] = await nc.query.blog.list();

// Get a specific blog post
const [page] = await nc.query.blog.get("page_id");

// Handle errors
const [data, error] = await nc.query.blog.list();
if (error) {
  console.error("Failed to fetch blog posts:", error);
}

Upgrade from the legacy CLI or SDK

The SDK and CLI now ship together in notcms. Update old dependency specs explicitly: init preserves an existing SDK version rather than upgrading it.

npm uninstall notcms-kit # Only if it is a project dependency
npm install notcms@latest
npx notcms pull
npx notcms pull --check

Keep notcms.config.json and your server-side credentials. Replace old notcms-kit init / notcms-kit pull scripts with notcms init / notcms pull. Regenerate the schema and typecheck your application before deploying an upgrade; this is especially necessary for prerelease SDKs such as 0.0.12-development. See the migration checklist for package-manager equivalents, CI usage, and compatibility checks.

Examples and Templates

Check out these examples to get started quickly:

Runnable example source lives under examples/.

Troubleshooting

Authentication Errors

If you see errors like "secretKey is required" or "workspaceId is required", make sure:

  1. Your environment variables are correctly set
  2. You're using the correct variable names (NOTCMS_SECRET_KEY and NOTCMS_WORKSPACE_ID)
  3. Your environment variables are being loaded properly

Schema Errors

If you encounter schema-related errors:

  1. Make sure your Notion database IDs are correct
  2. Verify that the property types match what's in your Notion database
  3. Try running npx notcms pull to regenerate your schema

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Note: This project uses Changesets for version management. When making changes that should be released, please run pnpm changeset to create a changeset describing your changes.

License

This project is organized as a monorepo with multiple packages:

See individual directories for specific license details.

Keep generated types in sync with PR and scheduled schema checks.

Build a blog with the Astro guide.

About

NotCMS makes it easy to create a headless CMS, from Notion

Topics

Resources

Contributing

Stars

19 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages