{"id":21468959,"url":"https://github.com/takux/notion-block-renderer","last_synced_at":"2025-09-01T05:31:51.967Z","repository":{"id":41210778,"uuid":"508288049","full_name":"takux/notion-block-renderer","owner":"takux","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-08T04:02:42.000Z","size":291,"stargazers_count":13,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-13T04:29:23.640Z","etag":null,"topics":["nextjs","notion","notion-api","react","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/notion-block-renderer","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-28T12:22:58.000Z","updated_at":"2024-02-13T01:32:54.000Z","dependencies_parsed_at":"2024-06-21T13:13:10.985Z","dependency_job_id":null,"html_url":"https://github.com/takux/notion-block-renderer","commit_stats":{"total_commits":177,"total_committers":1,"mean_commits":177.0,"dds":0.0,"last_synced_commit":"5d408fefead5cb96b3d323176a3b29ed707a5652"},"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"purl":"pkg:github/takux/notion-block-renderer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takux%2Fnotion-block-renderer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takux%2Fnotion-block-renderer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takux%2Fnotion-block-renderer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takux%2Fnotion-block-renderer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takux","download_url":"https://codeload.github.com/takux/notion-block-renderer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takux%2Fnotion-block-renderer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273077227,"owners_count":25041358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextjs","notion","notion-api","react","typescript"],"created_at":"2024-11-23T09:11:46.844Z","updated_at":"2025-09-01T05:31:51.662Z","avatar_url":"https://github.com/takux.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# notion-block-renderer\n\n\u003c!-- \u003e **Warning**   --\u003e\n\u003e v2.0.x ~: `isNextJS` of main props was removed.\n\n\u003e v2.3.x ~: Added new block type `table_of_contents`.\n\n\u003cbr /\u003e\n\nThis package is suitable for use with Reactjs or Nextjs. Notion blocks are rendered into React components. That component has a CSS class name corresponding to the block type. \n\nI'm a programmer ([@takumafujimoto](https://twitter.com/takumafujimoto)). I first created this feature for myself. Later, I thought it would be useful for everyone, so I made it public.\n\n\u003cbr /\u003e\n\n## Notion API verion\n\nThis package compatible to the `2022-02-22` and `2022-06-28` version of Notion API.\n\nNotion API version: https://developers.notion.com/reference/changes-by-version\n\n\u003cbr /\u003e\n\n\n## Install\n\n```\nnpm install notion-block-renderer\n```\nor\n\n```\nyarn add notion-block-renderer\n```\n\n\u003cbr /\u003e\n\n## Demo \u0026 Example\n\n- [Styled one-page exmale]()\n\n\u003cbr /\u003e\n\n## Usage\n\n```js\nimport NotionBlocks from \"notion-block-renderer\";\n\nconst Sample = ({ blocks }) =\u003e {\n    return (\n        \u003cdiv\u003e\n            \u003cNotionBlocks\n                blocks={blocks}\n            /\u003e\n        \u003c/div\u003e\n    );\n}\n\n```\n\nYou have to pass `blocks`. \n\n`blocks` is result of a response object as follows:\n\n```js\nconst { results: blocks }  = await notion.blocks.children.list({ block_id: id });\n``` \n\nFor more detail, see the Notion docs.\n\nhttps://developers.notion.com/reference/get-block-children\n\n\u003cbr /\u003e\n\n\n## Available Blocks\n\n\n| Block Type | \n| --- |\n| paragraph | \n| heading_1 | \n| heading_2 | \n| heading_3 | \n| bulleted_list_item | \n| numbered_list_item | \n| quote | \n| callout | \n| code | \n| image | \n| video | \n| table_of_contents | \n\n\n\n\u003cbr /\u003e\n\n## Code Block Usage\n\nBy default, code blocks are unstyled. The option `isCodeHighlighter` can be used to easily set the style. \n\nThis package defaults to [react-syntax-highlighter](https://www.npmjs.com/package/react-syntax-highlighter) when `isCodeHighlighter` is `true`. Use.\n\n```js\nconst Sample = ({ blocks }) =\u003e {\n    return (\n        \u003cdiv\u003e\n            \u003cNotionBlocks\n                blocks={blocks}\n                isCodeHighlighter={true}\n            /\u003e\n        \u003c/div\u003e\n    );\n}\n```\n\nYou can also set custom style CSS for the `syntaxHighlighterCSS` option. \n\nYou can choose to provide \n\n- your own CSS or\n- use [react-syntax-highlighter](https://www.npmjs.com/package/react-syntax-highlighter)'s style.\n\n\u003cbr /\u003e\n\n### react-syntax-highlighter style usage\n\n\u003c!-- \u003e **Warning**   --\u003e\n\u003e Only Highlight.js of `react-syntax-highlighter`(not Prism.js) is supported at this time. So please use to import from `\"react-syntax-highlighter/dist/cjs/styles/hljs\"`. See: [https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/](https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/)\n\nFirst you need to install `react-syntax-highlighter`.\n\nhttps://www.npmjs.com/package/react-syntax-highlighter\n\n\nThen import styles to use.\n\n```js\nimport {\n  monokaiSublime,\n  irBlack,\n  tomorrowNightBright,\n  monokai,\n} from \"react-syntax-highlighter/dist/cjs/styles/hljs\";\n\nconst Sample = ({ blocks }) =\u003e {\n    return (\n        \u003cdiv\u003e\n            \u003cNotionBlocks\n                blocks={blocks}\n                isCodeHighlighter={true}\n                syntaxHighlighterCSS={monokaiSublime}\n            /\u003e\n        \u003c/div\u003e\n    );\n}\n```\n\n\u003cbr /\u003e\n\n### your own CSS style usage\n\n`syntaxHighlighterCSS` has the following type.\n\n```js\n{\n    [key: string]: React.CSSProperties;\n}\n```\n\n\u003cbr /\u003e\n\n### Code block samples\n\n**Unstyled:**\n\u003cimg width=\"450\" alt=\"codeblock-unstyled\" src=\"https://user-images.githubusercontent.com/53621441/176984909-a2f7cdaa-e043-41eb-bb8b-5598322f159d.png\"\u003e\n\n**Styled:**\n\u003cimg width=\"450\" alt=\"codeblock-styled\" src=\"https://user-images.githubusercontent.com/53621441/176984906-fd1c5bc5-5eb3-4ea0-aa44-8bb8be0fa5f9.png\"\u003e\n\n\u003cbr /\u003e\n\n## CSS example\n\nhttps://github.com/takux/notion-block-renderer/tree/main/example/styles/tailwindcss-sample.css\n\n## Props\n\nThe `NotionBlocks` component has several props.\n\n\n| Prop name | Description | Default value | Example values |\n| --- | --- | --- | --- |\n| blocks | Notion api blocks. See [Notion docs](https://developers.notion.com/reference/get-block-children). | (None) | --- |\n| prefix | Add prefix to className of each html component. | \"nbr\" | --- |\n| blockPrefix | Add prefix to className of each block html component. | \"block\" | --- |\n| blocksPrefix | Add prefix to className of blocks html component. | \"blocks\" | --- |\n| isCodeHighlighter | Code block's style. If true, code blocks are styled by CSS. | false | true |\n| syntaxHighlighterCSS | If `isCodeHighlighter` is true, you can change style to your own CSS. Using [react-syntax-highlighter](https://www.npmjs.com/package/react-syntax-highlighter)'s styled CSS is easy way. | `tomorrowNightBright` | `monokaiSublime` |\n\n\n\u003cbr /\u003e\n\n### type\n\nThe props type for `blocks` is as follows. This is just a reference code. See currect type: [types.ts](https://github.com/takux/notion-block-renderer/blob/main/src/types/types.ts).\n\n\n```js\ntype BlocksProps = {\n  blocks: BlockType[];\n  prefix?: string;\n  blockPrefix?: string;\n  blocksPrefix?: string;\n  isCodeHighlighter?: boolean;\n  syntaxHighlighterCSS?: {\n    [key: string]: React.CSSProperties;\n  };\n};\n```\n\n\u003c!--  --\u003e\n\u003e The `BlockType` is our original  declarative type. The best way may refer to [@notionhq/client](https://www.npmjs.com/package/@notionhq/client)'s type. Replacing code would be taking time. So please contribute if you can.\n\n\n\u003cbr /\u003e\n\n## About me\n\n* [Twitter](https://twitter.com/takumafujimoto)\n\n* [My Homepage](https://takux.one/)\n\n* [MY Blog](https://www.rabbitriver.page/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakux%2Fnotion-block-renderer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakux%2Fnotion-block-renderer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakux%2Fnotion-block-renderer/lists"}