I absolutely love Next.js's Incremental Static Regenration.
However, I'm looking for a way to force static pages regeneration on demand. Ideally via a command that I can trigger with an API call when the data in my source db change.
The idea is to regenerate each page just once after each data change. I could enforce ISR pages regeneration simply with fetching the target pages after their revalidation interval, but I'm looking for a way not to regenerate them redundantly until data changes.
Any ideas if it's doable and how? :-)
Edit
Next.js 12.1 now supports On-demand ISR (Beta)
At the moment (Next.js 10.1.3) there is no native support for this feature, the only way to trigger a page revalidation is with an interval-based HTTP request.
However Next.js team is exploring on-demand (triggered via API route) revalidation (see also https://github.com/vercel/next.js/discussions/10721#discussioncomment-686)
and since this is a highly requested feature may be avaible in the future.
Here you can find an attempt for revalidate pages on demand, but it has serious caveats and is not production ready.
Sources :
Update a static page by event
super Incremental Static Regeneration