Skip to content

Notion-ClientThe type-safe way to use Notion

Transform your Notion workspace into a powerful TypeScript database

Installation

bash
bun add @interactive-inc/notion-client @notionhq/client

Quick Start

typescript
import { NotionTable } from "@interactive-inc/notion-client"
import { Client } from "@notionhq/client"

const client = new Client({ auth: process.env.NOTION_TOKEN })

const tasks = new NotionTable({
  client,
  dataSourceId: "your-database-id",
  properties: {
    title: { type: "title" },
    status: { type: "select", options: ["todo", "doing", "done"] },
    priority: { type: "number" },
  } as const,
})

const task = await tasks.create({
  properties: { title: "Build app", status: "todo", priority: 1 },
})

const { records } = await tasks.findMany({
  where: { status: "todo" },
  sorts: [{ field: "priority", direction: "asc" }],
})

await tasks.update(task.id, {
  properties: { status: "done" },
})

MIT License.