Created
September 22, 2023 13:58
-
-
Save Wanuja97/65f4f0c2223a632cac29d3cf04744505 to your computer and use it in GitHub Desktop.
Server Side Rendering 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`, { cache: 'no-store' }) | |
return res.json() | |
} | |
export default async function SSR() { | |
const result = await getDateTime() | |
const dateTime = result.datetime | |
return ( | |
<div> | |
<TimeCard title="Server Side Rendering" timestamp={dateTime} description="This timestamp generated inside the server."/> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment