ReactJs — Server-Side Rendering (SSR) with Next.js
Next.js enables server-side rendering and static site generation for React apps, improving performance and SEO.
export async function getServerSideProps() {
const res = await fetch('https://jsonplaceholder.typicode.com/posts');
const posts = await res.json();
return { props: { posts } };
}
export default function Home({ posts }) {
return (
<div>
{posts.map(post => (
<p key={post.id}>{post.title}</p>
))}
</div>
);
}