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 🙏

© 2024 – Pkg Stats / Ryan Hefner

notion2nextjs

v1.1.1

Published

You can render the contents of the Notion Page in react using the @notionhq/client

Downloads

9

Readme

Static Badge Static Badge

Get Started

Installation

npm install notion2nextjs

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.

import { Notion2Component } from 'notion2nextjs' 

const n2c = new Notion2Component({
  client: notionClient
})

Use the getPage function of the n2c object to get all blocks of that page.

const blocks = n2c.getPage('abb07387c63645bbbbf093859db799bf')

Use the NotionTemplate component to render blocks on the screen.

<NotionTemplate blocks={blocks} />

ReactJS Example

import { useState, useEffect } from "react";
import NotionTemplate from 'notion2nextjs/dist/NotionTemplate'

export default function Page() {
  const [data, setData] = useState([])

  useEffect(() => {
    fetch('your N2C getPage data server')
      .then((res) => setData(res.json()))
  }, []);
  
  return <NotionTemplate blocks={data} />
}

NextJS Example

// page.jsx
import { Client } from "@notionhq/client";
import NotionTemplate from 'notion2nextjs/dist/NotionTemplate'
import { Notion2Component } from "./notion2Component";

async function getData() {
  const notion = new Client({
    auth: process.env.NOTION_SECRET,
  })
  const n2c = new Notion2Component({
    client: notion,
  })
  return n2c.getPage('your notion page id')
}

export default async function Page() {
  const data = await getData()
  
  return <CsrComponent data={data} />
}
// csrComponent.jsx
'use client'

import NotionTemplate from 'notion2nextjs/dist/NotionTemplate'

export default function CsrComponent({data}) {
  return <NotionTemplate blocks={data} />
}

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 | ✅ | | Pdf | ❌ | | Quote | ✅ | | SyncedBlock | ❌ | | Table | ✅ | | TableOfContents | ❌ | | TableRow | ✅ | | Template | ❌ | | ToDo | ✅ | | Toggle | ✅ | | Video | ✅ |