Skip to content

Instantly share code, notes, and snippets.

@Wanuja97
Created September 22, 2023 13:58
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/65f4f0c2223a632cac29d3cf04744505 to your computer and use it in GitHub Desktop.
Save Wanuja97/65f4f0c2223a632cac29d3cf04744505 to your computer and use it in GitHub Desktop.
Server Side Rendering in Next.js
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