Avatar of Faraz PatankarFaraz Patankar

Our blog is now on the Notion public API

In one of our first posts on this blog, we talked about how we had built it using Notion as our CMS and the advantages of doing so as it allows our entire team to collaborate on the posts without having to open up their code editors or deal with any sort of code at all.

While that was great (and still is), the blog was built on top of the private Notion API as they didn't quite have a public one at that time. And the biggest issue was that we'd randomly get rate limited and our blog would stop working. To fix this, we restructured our blog to use the recently launched Notion public API.

We've still kept the entire codebase open-source, which you can find here but, the instructions for deploying your own version of our blog have slightly changed. The good thing is, they're easier than they were before.

Setting up

To get started, click the button above. This should take you to our template deployment UI where you'll be asked to enter two mandatory environment variables. Both of which can be acquired following Notion's own getting started guide.

  • NOTION_API_TOKEN: In step one of the guide, you're asked to create an integration. Once you create one, you'll be shown an internal integration token. Copy that and use it as the value for your NOTION_API_TOKEN.
  • POSTS_TABLE_ID: In step two of the guide, you should either be using an existing table or create a new one and inviting your newly created integration to the page. This step gives access to the integration to read and write to your page. Once you do that, copy the database ID from the URL and use that as the value for your POSTS_TABLE_ID.

Deploying

Once you've added both the required environment variables, you can go ahead and click the deploy button. Your blog should now be live and any content you add on Notion in your posts database should start appearing on your blog.

Notes

  • The types we support for each post in the posts table can be found in this file.
  • We use Fathom for analytics, if you use something else, you might want to remove/replace this hook.