Tilda now supports Incremental Static Regeneration (ISR) with on-demand revalidation for Next.js projects. ISR allows you to cache some parts of your website for a custom duration and update the content of your Next.js website without rebuilding the entire site.
Tilda supports caching at all layers required for all Next.js features to work seamlessly. This includes:
- Static site generation (SSG)
- Server-side rendering (SSR)
- Incremental Static Regeneration (ISR)
How to use Next.js ISR with Tilda
We've recently made it really easy to migrate your existing Next.js projects or deploy new ones to Tilda with zero configuration or changes to your project. You can deploy your Next.js project to Tilda with a single command. See "Zero config Next.js deployments with Tilda" for more information.
Once your project is deployed to Tilda, you don't need to make any changes to your project to take advantage of ISR. Tilda will automatically plug in its caching infrastructure and everything will work out of the box.
Similarly, for on-demand revalidation, there's no Tilda-specific changes required. You can use standard Next.js primitives to purge and revalidate incremental cache.
Using revalidatePath()
import { revalidatePath } from 'next/cache'
revalidatePath('/blog/post-1')
Using revalidateTag()
import type { NextRequest } from 'next/server'
import { revalidateTag } from 'next/cache'
export async function GET(request: NextRequest) {
const tag = request.nextUrl.searchParams.get('tag')
revalidateTag(tag)
return Response.json({ revalidated: true, now: Date.now() })
}
Why use Next.js ISR
Using ISR results in lower build times and faster page loads because of content being cached at CDN edge locations. This is especially useful for pages that are updated frequently or require near real-time data.
ISR also reduces compute costs by serving more requests from caching rather than server-side rendering (SSR). This means that your website can handle more traffic without increasing your infrastructure costs.