notion-apinotion

Is it possible to "publish to web" using the Notion API, similar to the Notion app?


I'm working with the Notion API and I'm trying to replicate the functionality of "Publish to web" that is available directly in the Notion app. Specifically, I want to be able to programmatically publish a Notion page to the web via the API, but I haven't found any documentation on whether this is possible.

Has anyone had any success with publishing a page to the web via the Notion API? Is there a workaround or an official method for this? Any insight or guidance would be greatly appreciated!

Thanks in advance!


Solution

  • Hey hey just a thought since it's kinda fresh in my head. While there isn't a direct "Publish to Web" API endpoint in Notion, you can achieve similar functionality by building a custom solution. Here's how I've implemented something similar:

    1. Without ISR (Manual Updates): When deployed to Vercel without Incremental Static Regeneration (ISR), the site would only update when manually redeployed. This is somewhat similar to Notion's "Publish to Web" feature (in a way, I guess?), where you need to manually trigger an update.

    2. With ISR (Near Real-Time Updates): By implementing ISR with a short revalidation period (e.g., 60 seconds), the website automatically updates with the latest Notion content. This creates a near real-time sync between your Notion database and the published web page.

    This method gives you more control over the published output while maintaining a connection to your Notion content. I guess it's not exactly the same as Notion's "Publish to Web", as per your question but it might achieve a similar goal of making your Notion content publicly accessible and regularly updated (am assuming you were wanting to publish Notion content?)