Personalization in JSS SSG mode

Jack Spektor
2 min readApr 26, 2021

Hi

As you know JSS as amazing it is doesn’t support personalization in static-site generation (SSG) mode.

And if you haven’t seen Adam Lamarre (https://twitter.com/erzr) made an amazing solution for solving this issue.

I’ve decided to add some improvements to the solution which would solve the following things:

  • Call the layout service only when we need (on the pages which have the personalized content)
  • Support dynamic placeholders

For this to happen we are going to extend the JSS context and add the information with the list of personalized placeholders from the BE.

We are going to extend the JssGetLayoutServiceContextProcessor class and add the pipeline to getLayoutServiceContext pipeline

Now our context has additional data about current page personalization that we could use.

Extended context information for JSS

We are going to compare the list of renderings that is passed to our placeholder props data with the list of personalized renderings that we pass through to the context.

And if there is any personalization in the placeholder — only then we are going to make a call to the layout service.

--

--

Jack Spektor

Sitecore MVP 2018–2020, Sitecore Developer in AKQA, traveler and lover of life.