// posts will be populated at build time by getStaticProps()
function Blog({ posts }) {
return (
{posts.map((post) => (
- {post.title}
))}
)
}
// This function gets called at build time on server-side.
export async function getStaticProps() {
const res = await fetch('https://.../posts')
const posts = await res.json()
return {
props: {
posts
}
}
}
export default Blog
// From https://nextjs.org/docs/basic-features/data-fetching