You can render the contents of the Notion Page in react using the @notionhq/client
Installations
npm install @hibernationit/notion2component
Developer Guide
Typescript
Yes
Module System
CommonJS, UMD
Node Version
18.18.0
NPM Version
9.8.1
Score
24.4
Supply Chain
57.3
Quality
63
Maintenance
50
Vulnerability
90.1
License
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
HibernationIT
Download Statistics
Total Downloads
582
Last Day
1
Last Week
4
Last Month
31
Last Year
150
GitHub Statistics
45 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Oct 05, 2023
Package Meta Information
Latest Version
1.1.0
Package Id
@hibernationit/notion2component@1.1.0
Unpacked Size
116.04 kB
Size
17.73 kB
File Count
116
NPM Version
9.8.1
Node Version
18.18.0
Published on
Oct 14, 2023
Total Downloads
Cumulative downloads
Total Downloads
582
Last Day
0%
1
Compared to previous day
Last Week
-60%
4
Compared to previous week
Last Month
244.4%
31
Compared to previous month
Last Year
-65.3%
150
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
10
Dev Dependencies
20
Notion2Component
You can render the contents of the Notion Page in react using the @notionhq/client
Get Started
Installation
1npm install @hibernationit/notion2component
Advice
The getPage function of the notion2component module cannot be called from the browser. Therefore, you must use a server side rendering (SSR) environment or implement a server that calls data. We recommend using nextjs rather than reactjs. However, because the Notion Template component is a client side rendering (CSR), you must create a CSR component when using nextjs.
Usage
Create a client object by referencing the @notionhq/client document and create an n2c object using that object.
1import { Notion2Component } from '@hibernationit/notion2component' 2 3const n2c = new Notion2Component({ 4 client: notionClient 5})
Use the getPage function of the n2c object to get all blocks of that page.
1const blocks = n2c.getPage('abb07387c63645bbbbf093859db799bf')
Use the NotionTemplate component to render blocks on the screen.
1<NotionTemplate blocks={blocks} />
ReactJS Example
1import { useState, useEffect } from "react"; 2import NotionTemplate from '@hibernationit/notion2component/dist/NotionTemplate' 3 4export default function Page() { 5 const [data, setData] = useState([]) 6 7 useEffect(() => { 8 fetch('your N2C getPage data server') 9 .then((res) => setData(res.json())) 10 }, []); 11 12 return <NotionTemplate blocks={data} /> 13}
NextJS Example
1// page.jsx 2import { Client } from "@notionhq/client"; 3import NotionTemplate from '@hibernationit/notion2component/dist/NotionTemplate' 4import { Notion2Component } from "./notion2Component"; 5 6async function getData() { 7 const notion = new Client({ 8 auth: process.env.NOTION_SECRET, 9 }) 10 const n2c = new Notion2Component({ 11 client: notion, 12 }) 13 return n2c.getPage('your notion page id') 14} 15 16export default async function Page() { 17 const data = await getData() 18 19 return <CsrComponent data={data} /> 20}
1// csrComponent.jsx 2'use client' 3 4import NotionTemplate from '@hibernationit/notion2component/dist/NotionTemplate' 5 6export default function CsrComponent({data}) { 7 return <NotionTemplate blocks={data} /> 8}
Supporting Blocks
Block Type | Supported |
---|---|
Bookmark | ✅ |
Breadcrumb | ❌ |
BulletedListItem | ✅ |
Callout | ✅ |
ChildDatabase | ❌ |
ChildPage | ❌ |
Column | ✅ |
ColumnList | ✅ |
Divider | ✅ |
Embed | ❌ |
Equation | ✅ |
File | ✅ |
Heading_1 | ✅ |
Heading_2 | ✅ |
Heading_3 | ✅ |
Image | ✅ |
LinkPreview | ❌ |
LinkToPage | ❌ |
NumberedListItem | ✅ |
Paragraph | ✅ |
❌ | |
Quote | ✅ |
SyncedBlock | ❌ |
Table | ✅ |
TableOfContents | ❌ |
TableRow | ✅ |
Template | ❌ |
ToDo | ✅ |
Toggle | ✅ |
Video | ✅ |

No vulnerabilities found.

No security vulnerabilities found.