npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@notion-headless-cms/client

v0.3.9

Published

notion-headless-cms 単一エントリ — createCMS で schema(構造) と振る舞いを分離して組み立てる

Readme

@notion-headless-cms/client

createCMS 単一エントリ。DB の構造は schema(生成物)、それ以外の振る舞いは createCMS の引数で定義する。createClient + notionSource + preset の合成を 1 つに集約する。

v2 使い勝手再設計(RFC: docs/ja/rfc/v2-usability-redesign.md)の最初の実装。

インストール

pnpm add @notion-headless-cms/client @notion-headless-cms/cli
pnpm add @notionhq/client zod notion-to-md

使い方(Node)

import { createCMS } from "@notion-headless-cms/client";
import { schema } from "./generated/nhc";

export const cms = createCMS({
  notion: {
    schema,
    token: process.env.NOTION_TOKEN!,
    collections: { posts: { published: ["公開済み"] } },
  },
  render: { content: "html" }, // "html" | "react"(取得戦略 + renderer を内部結線)
  // cache 省略時は in-process memory が既定(document / image 兼用)
});

const posts = await cms.posts.list();
const post = await cms.posts.find("my-first-post");
const html = await post?.html();

使い方(Cloudflare / Next)

cache に役割別(document / image)でアダプタを明示する。

import { createCMS } from "@notion-headless-cms/client";
import { kvCache, r2Cache } from "@notion-headless-cms/client/cloudflare";

export const makeCms = (env: Env, ctx: ExecutionContext) =>
  createCMS({
    notion: {
      schema,
      token: env.NOTION_TOKEN,
      collections: { posts: { published: ["公開済み"] } },
    },
    render: { content: "react" },
    cache: {
      document: kvCache({ namespace: env.DOC_CACHE }),
      image: r2Cache({ bucket: env.IMG_BUCKET }),
      waitUntil: (p) => ctx.waitUntil(p),
    },
  });

content モードと型

| content | アイテムに生えるアクセサ | |---|---| | "html" | html() / markdown() | | "react" | notionBlocks()undefined にならない) |

content モードでアクセサ型が切り替わるため、"html"notionBlocks() を呼ぶような 不整合は型エラーになる。

責務分割

| 情報 | 住所 | |---|---| | DB 構造(id / properties / slugField / statusField) | schemanhc generate) | | 取得元(schema / token / 公開ポリシー) | createCMS({ notion }) | | 出力先(content / OGP) | createCMS({ render }) | | キャッシュ戦略(document / image / swr / waitUntil) | createCMS({ cache }) |