What is server-side rendering (SSR) in React, and why is it important?

SSR renders React components on the server instead of the client, sending pre-rendered HTML to the browser, which improves initial load speed and SEO. Next.js is commonly used for SSR in React applications.

export async function getServerSideProps() {
  const res = await fetch('https://jsonplaceholder.typicode.com/posts');
  const data = await res.json();
  return { props: { data } };
}