2

How could we apply Hybrid (SSG and SSR) rendering in a single Sitecore Nextjs application?

We tried this article:

https://github.com/Sitecore/jss/tree/release/18.0.0/samples/nextjs/src/pages https://doc.sitecore.com/xp/en/developers/hd/200/sitecore-headless-development/prerendering-methods-and-data-fetching-strategies-in-jss-next-js-apps.html

But it doesn't work together (SSR AND SSG). Getting 502 error.

1
  • Did you get it to work?
    – chilly
    Commented Mar 28, 2023 at 6:29

1 Answer 1

3

An easy way to apply hybrid rendering (SSG and SSR) with Sitecore and Next.js, you can utilize different routes and configurations.

First, for your default routes, you can leverage static site generation (SSG) by keeping the [[...path]].tsx file. This allows you to pre-render pages at build time and serve them as static HTML files. This approach is ideal for pages that do not require real-time data and can be cached for improved performance.

However, if you have specific routes or pages that require server-side rendering (SSR) to handle dynamic content or data fetching, you can create sub-routes or specific paths to cater to these scenarios. For example, you can create a route like pages/account/[[...path]].tsx and configure it to use SSR. This way, when a user accesses this route, the server will generate the page on the fly, incorporating real-time data or executing server-side logic before sending the response to the client.

But these solutions may vary according to the needs of your project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.