Incremental static regeneration lets you pre‑render Next.js blog posts and update them on demand, while CMSKite webhooks trigger instant revalidation without a full rebuild.
Quick Answer: How ISR Works for Blog Posts
Incremental static regeneration (ISR) lets you pre‑render a blog post at build time and then update that page on demand when the content changes. In Next.js you turn on ISR by returning a revalidate value from getStaticProps. The page stays in the edge cache until the next request after the interval, at which point Next.js regenerates it in the background. CMSKite adds a webhook that can call the revalidation API immediately after an editor saves changes, so the page is fresh without waiting for the next interval. This combination gives you the performance of static pages and the freshness of dynamic content.
Setting Up the Project
Start by creating a fresh Next.js application with npx create-next-app. Once the scaffold is ready, add the CMSKite SDK: npm i @cmskite/sdk. Create a .env.local file and define the keys required by CMSKite, such as CMSKITE_API_KEY and a secret token for webhook verification. If you plan to deploy on Vercel, also add the Vercel webhook URL that CMSKite will call after a content update. Install any additional dependencies you need for fetching data from your headless CMS, for example axios or the official CMSKite client. With the environment set, you can start building the pages that will use ISR.
Configuring getStaticProps with Revalidate
In the page component for a single post, export an async getStaticProps function. Inside it, fetch the post data from your headless CMS using the CMSKite SDK or a REST call. Return an object containing props with the post data and a revalidate field that tells Next.js how often the page can be regenerated. For new posts that are not yet generated, choose a fallback strategy: blocking ensures search engines receive a fully rendered page, while true gives a faster navigation experience for logged‑in users. Below is a complete snippet that demonstrates fetching, returning props, and setting the fallback mode.
export async function getStaticProps({ params }) {
const post = await cmskiteClient.getPost(params.slug);
return {
props: { post },
revalidate: "60s", // interval can be adjusted in the dashboard
// fallback: "blocking" or true, see next section
};
}
Integrating CMSKite SDK for On‑Demand ISR
Create an API route at pages/api/revalidate.js. Inside, verify the secret token sent by CMSKite, then call res.revalidate(/posts/${slug}). This tells Next.js to rebuild the specific page immediately. Use the CMSKite SDK to register a webhook that points to this endpoint; the webhook should fire after any content update, deletion, or publish event. The registration code looks like this:
await cmskiteClient.createWebhook({
url: process.env.VERCEL_REVALIDATE_URL,
secret: process.env.WEBHOOK_SECRET,
events: ["post.updated", "post.published"]
});
Secure the endpoint by checking the incoming Authorization header against the secret you stored. If the verification fails, return a 401 response. This on‑demand approach means your blog pages stay current the moment an editor publishes a change.
Adding Preview Mode for Authors
Next.js preview mode lets authors view drafts without publishing. Implement a preview API route (pages/api/preview.js) that checks a secret token, sets the preview cookie, and redirects to the requested slug. When preview mode is active, modify getStaticProps to fetch draft content from CMSKite instead of only published data. Combine this with ISR by keeping the revalidate value; preview requests will always fetch the latest draft, while regular visitors receive the cached static version that updates on the next revalidation cycle. This workflow ensures that content creators see their changes instantly while the public sees stable, SEO‑friendly pages.
Keeping SEO Metadata Fresh
SEO tags such as Open Graph, JSON‑LD, and standard meta descriptions should reflect the latest post data. Inside the page component, build a helper that merges the CMSKite fields (title, description, image) with default SEO values. Whenever those fields change, the CMSKite webhook you set up earlier will trigger a revalidation, automatically updating the meta tags on the next request. Example helper:
export function buildSeo({ title, description, image }) {
return {
title,
description,
openGraph: { images: [{ url: image }] },
jsonLd: { "@type": "Article", headline: title, image }
};
}
Use the returned object in the <Head> component to keep search engine previews accurate without manual intervention.
Deploying and Testing on Vercel
Push the repository to GitHub and import it into Vercel. Enable the “Incremental Regeneration” feature in the project settings. After the first deployment, go to the CMSKite dashboard and trigger a manual webhook call to verify that the revalidation endpoint works. Visit a post page, edit its content in the CMS, and watch the page update on the next request without a full rebuild. Compare the experience: a full static build would require a redeploy, while ISR updates happen instantly, giving you a smoother publishing workflow.
Ready to supercharge your Next.js blog? Try the free CMSKite SDK and see ISR in action today.
Frequently asked questions
What is the purpose of the `revalidate` field in getStaticProps?
It tells Next.js how often a static page can be regenerated, enabling incremental updates after the initial build.
Do I need to use Vercel to get ISR working?
No, ISR works on any Node.js serverless platform that supports Next.js, though Vercel provides a streamlined setup.
How does preview mode differ from ISR?
Preview mode fetches draft content on each request for editors, while ISR serves cached pages that refresh on the revalidation schedule.
What security measure should I add to the revalidation API route?
Validate a secret token sent by CMSKite before calling `res.revalidate` to prevent unauthorized page rebuilds.
Will SEO metadata update automatically after a content change?
Yes, when the CMSKite webhook triggers revalidation, the page regenerates with the latest meta tags generated by your helper function.

