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.
- 🛡️ 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 notcms-kit for easy project setup and schema management
npm install notcmsCreate a .env file in your project root:
NOTCMS_SECRET_KEY=your_secret_key
NOTCMS_WORKSPACE_ID=your_workspace_idYou can get these values from the NotCMS Dashboard.
NotCMS Kit provides command-line tools to streamline your workflow. You can use it directly with npx:
npx notcms-kit initThis will create a notcms.config.json file in your project root.
The easiest way to define your schema is to use NotCMS Kit:
npx notcms-kit pullThis will automatically fetch your database schema from Notion and generate a TypeScript schema file.
For reference, the generated schema will look something like this:
// src/notcms/schema.ts
import { Client, Schema } from "notcms";
export const schema = {
blog: {
id: "your_notion_database_id",
properties: {
title: "title",
description: "rich_text",
published: "checkbox",
thumbnails: "files",
// Run notcms-kit pull again when properties are updated
},
},
} satisfies Schema;
export const nc = new Client({ schema });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);
}Check out these examples to get started quickly:
If you see errors like "secretKey is required" or "workspaceId is required", make sure:
- Your environment variables are correctly set
- You're using the correct variable names (
NOTCMS_SECRET_KEYandNOTCMS_WORKSPACE_ID) - Your environment variables are being loaded properly
If you encounter schema-related errors:
- Make sure your Notion database IDs are correct
- Verify that the property types match what's in your Notion database
- Try running
npx notcms-kit pullto regenerate your schema
We welcome contributions! Please see our Contributing Guide for details.
This project is organized as a monorepo with multiple packages:
packages/notcms: MIT Licensepackages/notcms-kit: MIT Licenseexamples/: MIT License
See individual directories for specific license details.