Trigger Prismic Webhook only when a document is published for the first time


I have a static a webhook which triggers a new build when a document is published/unpublished. It works well, however there are a lot of unnecessary builds since I have incremental static regeneration turned on.

So I really need a webhook to rebuild the website only when there are new pages published on the website, then incremental static regeneration can take for any subsequent updates.

Do you have any advice on how I could achieve this?


Hi Kristiyan,

Thank you for contributing to the Prismic community.

Well if I understand correctly to avoid to rebuild your whole project when documents get modified is to have some sort of middleware (such as a Lambda function)

Get the list of the changed documents from the webhook like this

And do a query to your document from Prismic and check if the First publication date is not much older than the last modification date then you can allow it to rebuild everything.

Also, I'm curious, what system you are using to achieve incremental static regeneration of subsequent updates.

I don't know if that answers your question? please let me know!


This issue has been closed due to inactivity. Flag to reopen.