MCPcopy
hub / github.com/splitbee/react-notion

github.com/splitbee/react-notion @v0.10.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.10.0 ↗
59 symbols 90 edges 14 files 1 documented · 2%
README

react-notion

npm version npm version minzipped sized

A React renderer for Notion pages. Use Notion as CMS for your blog, documentation or personal site.

react-notion was developed by Splitbee. Splitbee is a fast, reliable, free, and modern analytics for any team.

This package doesn't handle the communication with the API. Check out notion-api-worker for an easy solution.

Created by Timo Lins & Tobias Lins with the help of all contributors ❤️

Features

⚡️ Fast – Up to 10x faster than Notion*

🎯 Accurate – Results are almost identical

🔮 Code Highlighting – Automatic code highlighting with prismjs

🎨 Custom Styles – Styles are easily adaptable. Optional styles included

* First Meaningful Paint compared to a hosted example on Vercel.

react-notion is best suited as minimal renderer for blogs & content pages. If you're looking for a full-featured solution to render Notion-like pages, check out react-notion-x.

Install

npm install react-notion

How to use

Minimal Example

We can store the API response in a .json file and import it.

import "react-notion/src/styles.css";
import "prismjs/themes/prism-tomorrow.css"; // only needed for code highlighting
import { NotionRenderer } from "react-notion";

import response from "./load-page-chunk-response.json"; // https://www.notion.so/api/v3/loadPageChunk

const blockMap = response.recordMap.block;

export default () => (



    <NotionRenderer blockMap={blockMap} />



);

A working example can be found inside the example directory.

Next.js Example

In this example we use Next.js for SSG. We use notion-api-worker to fetch data from the API.

/pages/my-post.jsx

import "react-notion/src/styles.css";
import "prismjs/themes/prism-tomorrow.css";

import { NotionRenderer } from "react-notion";

export async function getStaticProps() {
  const data = await fetch(
    "https://notion-api.splitbee.io/v1/page/<NOTION_PAGE_ID>"
  ).then(res => res.json());

  return {
    props: {
      blockMap: data
    }
  };
}

export default ({ blockMap }) => (



    <NotionRenderer blockMap={blockMap} />



);

Sites using react-notion

List of pages that implement this library.

Supported Blocks

Most common block types are supported. We happily accept pull requests to add support for the missing blocks.

Block Type Supported Notes
Text ✅ Yes
Heading ✅ Yes
Image ✅ Yes
Image Caption ✅ Yes
Bulleted List ✅ Yes
Numbered List ✅ Yes
Quote ✅ Yes
Callout ✅ Yes
Column ✅ Yes
iframe ✅ Yes
Video ✅ Yes Only embedded videos
Divider ✅ Yes
Link ✅ Yes
Code ✅ Yes
Web Bookmark ✅ Yes
Toggle List ✅ Yes
Page Links ✅ Yes
Header ✅ Yes Enable with fullPage
Databases ❌ Missing Not planned. Supported by react-notion-x
Checkbox ❌ Missing Supported by react-notion-x
Table Of Contents ❌ Missing Supported by react-notion-x

Block Type Specific Caveats

When using a code block in your Notion page, NotionRenderer will use prismjs to detect the language of the code block. By default in most project, prismjs won't include all language packages in the minified build of your project. This tends to be an issue for those using react-notion in a next.js project. To ensure the programming language is correctly highlighted in production builds, one should explicitly imported into the project.

import 'prismjs/components/prism-{language}';

Credits

Extension points exported contracts — how you extend this code

BaseValueType (Interface)
* Base properties that all blocks share.
src/types.ts
NotionRendererProps (Interface)
(no doc)
src/renderer.tsx
Block (Interface)
(no doc)
src/block.tsx
AssetProps (Interface)
(no doc)
src/components/page-icon.tsx
PageValueType (Interface)
(no doc)
src/types.ts
PageHeaderProps (Interface)
(no doc)
src/components/page-header.tsx
BaseTextValueType (Interface)
(no doc)
src/types.ts
BookmarkValueType (Interface)
(no doc)
src/types.ts

Core symbols most depended-on inside this repo

classNames
called by 6
src/utils.ts
getTextContent
called by 5
src/utils.ts
renderComponent
called by 3
src/block.tsx
wrapList
called by 2
src/block.tsx
groupBlockContent
called by 1
src/utils.ts
getListNumber
called by 1
src/utils.ts
createRenderChildText
called by 1
src/block.tsx
renderText
called by 1
src/block.tsx

Shape

Interface 36
Function 23

Languages

TypeScript100%

Modules by API surface

src/types.ts32 symbols
src/utils.ts6 symbols
src/block.tsx6 symbols
src/components/page-icon.tsx3 symbols
src/renderer.tsx2 symbols
src/components/page-header.tsx2 symbols
example/pages/index.tsx2 symbols
example/pages/[pageId].tsx2 symbols
tsdx.config.js1 symbols
src/components/code.tsx1 symbols
src/components/asset.tsx1 symbols
example/pages/_app.tsx1 symbols

Dependencies from manifests, versioned

@types/node13.13.0 · 1×
@types/prismjs1.16.1 · 1×
@types/react16.9.43 · 1×
@types/react-dom16.9.8 · 1×
husky4.2.5 · 1×
next9.5.4 · 1×
node-fetch2.6.0 · 1×
prismjs1.21.0 · 1×
react16.13.1 · 1×
react-dom16.13.1 · 1×
react-notion0.9.3 · 1×
rollup-plugin-copy3.3.0 · 1×

For agents

$ claude mcp add react-notion \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact