Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Gatsby source plugin that pulls Notion pages into GraphQL nodes with Markdown output via the official Notion API.
Gatsby Source Notion API is a Gatsby source plugin that pulls pages from a Notion database through the official Notion API and exposes them as GraphQL nodes with Markdown output.
Gatsby Source Notion API is an open-source Gatsby source plugin that connects to the official Notion API (currently in beta) to retrieve pages from a specific database. It requires a Notion integration token and a database ID as configuration, then creates Gatsby GraphQL nodes containing page properties, Markdown-converted content, and raw API data. The plugin supports both gatsby-transformer-remark and gatsby-plugin-mdx, and was built by orlowdev, the author of the orlow.dev blog, which runs on this plugin.
allNotion or a single node via notion, with fields for title, properties, archived, createdAt, updatedAt, markdown, and raw.notion-color attribute; unsupported blocks become HTML comments.properties object with id, key, value, and type subfields, and can be injected into Markdown frontmatter via propsToFrontmatter.raw node property holds the untouched Notion API response, useful for consuming block types not yet converted.gatsby-transformer-remark and MDX, so you can query with allMarkdownRemark or customize components through MDXProvider.lowerTitleLevel option (true by default) shifts # headings one level down to accommodate Notion's three-level heading limit and allow deeper headings in Markdown.gatsby-config.js, point it at a database, and query the content with GraphQL.ColumnList and Column components that are customizable.onCreateNode hook and createRemoteFileNode.raw property to inspect the complete API response for blocks that aren't yet converted to Markdown.allMarkdownRemark queries directly to get rendered HTML from the Notion content, with frontmatter containing your database columns.Install via yarn add gatsby-source-notion-api or npm install --save gatsby-source-notion-api, create a Notion integration to obtain a token, share the target database with that integration, and copy the database ID from the URL. Then add the plugin to gatsby-config.js with token and databaseId; during the Gatsby build, the plugin fetches pages, converts them to Markdown, and creates GraphQL nodes.
propsToFrontmatter and lowerTitleLevel.The plugin is open-source and available for free on npm; it uses the official Notion API, which requires a Notion integration token that you create yourself.
The README states that some blocks are marked "unsupported" by the Notion API, and images cannot be fetched at this time. Unsupported blocks are turned into HTML comments in the Markdown output.
Yes, the plugin supports both markdown-remark and mdx, so you can query through allMarkdownRemark or use MDXProvider to customize components like column lists.
As of now, the plugin works with only one database per plugin configuration. The README notes that future releases will make all databases reachable by the integration available for querying.
lowerTitleLevel do?When set to true (the default), it shifts every heading one level down (# becomes ##), because Notion itself supports only three heading levels; this lets you use #### and deeper in Markdown even though Notion won't display them.
