How to use Next.js on-demand ISR?

What is the best way for us to use Plasmic with the new NextJs On-demand ISR? Documentation shows revalidating a single link. Is it possible for Plasmic to send to an API route that we create the paths to the pages that we modified in the editor? And would you be willing to create a code snippet showing how this would look? And maybe include this in the documentation of Plasmic? Thanks!

With a webhook when you publish?

Yes, when you publish you can hit a webhook on your end that performs the invalidation. There’s no way for the webhook to know which pages have been updated right now though, so you’ll have to invalidate all the Plasmic pages…

Such an amazing feature. I think Plasmic would need to expose a version history endpoint that could be called from within a Next webhook receiver triggered by a publish action inside of Plasmic. If that returned a set of pages that had been updated since the last publish you could trigger each of them to regenerate.

Invalidating all pages on Plasmic publish might still prove to be more cost / resource effective than timed invalidation if Plasmic was your only source of dynamic data

depends on traffic and page count though I suppose

Yeah right now for my project invalidating every page that Plasmic is providing designs for would be the whole website: 1000+ pages. So until we get a per page webhook system from Plasmic, I don’t see an advantage of the using the new revalidation feature instead of the current timed invalidation. I hope we can get this added to the Plasmic roadmap since Plasmic seems to be focusing on NextJS as a first class system with Codegen and Loader.

1 Like