Created
September 22, 2023 14:01
-
-
Save Wanuja97/3286a89c4c15b9b8ba4e83429ce9f067 to your computer and use it in GitHub Desktop.
Incremental Static Regeneration in Next.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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