Sure, here's an example of Incremental Static Regeneration (ISR) with the app router. This example uses the fetch function with the revalidate option to cache the request for a specified amount of seconds.
async function getPosts() {
const res = await fetch(`<https://.../posts`,> { next: { revalidate: 60 } })
const data = await res.json()
return data.posts
}
export default async function PostList() {
const posts = await getPosts()
return posts.map((post) => <div>{post.name}</div>)
}
In this example, the getPosts function fetches posts from a specified URL and sets the revalidate option to 60 seconds. This means that the fetched data will be cached and revalidated every 60 seconds. The PostList function then uses the getPosts function to fetch the posts and render them (source (https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration)).
Please replace <https://.../posts> with your actual API endpoint.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: