CMS + Next.js: Server Side Rendering (SSR)

This section provides an overview of how to implement server-side rendering (SSR) in a Next.js application using Apollo Client to fetch and display CMS data.

When you use SSR?

Server-side rendering (SSR) is particularly useful when you want to ensure that your application has the following characteristics:

  • SEO Optimization: SSR allows search engines to crawl your pages more effectively, as the content is rendered on the server before being sent to the client.
  • Faster Initial Load: By rendering the initial HTML on the server, users can see the content more quickly.
  • Data Fetching: SSR is beneficial when you need to fetch data from an API before rendering the page.
  • Dynamic Content: If your application has dynamic content that changes frequently, SSR can help ensure that users always see the most up-to-date information.
  • Improved User Experience: By serving fully rendered pages, SSR can enhance the overall user experience.

⚠️ In other words you should use SSR on all page.tsx files that are not marked with "use client" directive.

How to implement SSR in Next.js with Apollo Client

To implement SSR, you typically:

  • Fetch data in server components.
  • Use your Apollo client setup for server-side queries.
  • Render the result as part of the initial HTML.
Edit this page