Currently, NextResponse does not support res.revalidate('/')
. I am working with version v12.2.5
, although this feature has been available since v12.2.0
. My goal is to implement on-demand ISR using TypeScript.
Learn more about on-demand Incremental Static Regeneration in Next.js 12.2 here
export default async function handler(req: NextRequest, res: NextResponse) {
try {
await res.revalidate('/');
return res.json({ revalidated: true });
} catch (err) {
console.error(err);
return res.status(500).send('Error revalidating');
}
}