Skip to content

Instantly share code, notes, and snippets.

@Wanuja97
Created September 22, 2023 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wanuja97/3286a89c4c15b9b8ba4e83429ce9f067 to your computer and use it in GitHub Desktop.
Save Wanuja97/3286a89c4c15b9b8ba4e83429ce9f067 to your computer and use it in GitHub Desktop.
Incremental Static Regeneration in Next.js
import React from 'react'
import TimeCard from './TimeCard'
async function getDateTime() {
const res = await fetch(`https://worldtimeapi.org/api/ip`, { next: { revalidate: 20 } })
return res.json()
}
export default async function ISR() {
const result = await getDateTime()
const dateTime = result.datetime
return (
<div>
<TimeCard title="Incremenral Static Regeneration" timestamp={dateTime} description="This timestamp generated inside the server and it regenerating this component in each 20 seconds. Refresh the page in each 20 seconds for see the change"/>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment