1

I installed SSR to Spartacus application with schematics command and run the application in SSR mode.

In my Chrome dev tools, I can see that content of my homepage was successfully generated by the SSR server.

However, I can see in my network tab, that the XHR requests are still sent and data is fetched with http calls instead of using data fetched by express.

I tried to use config from https://sap.github.io/spartacus-docs/ssr-transfer-state/#page-title in my app.module.ts providers with provideConfig (I also tried it with Config.Module.withConfig in app.module.ts imports as well) file but it didn't work, as CMS and products requests were still sent from client.

At the end of my rendered HTML I can see that state data is linked in key value format to script tag:

<script id="spartacus-state" type="application/json">...</script>

I am wondering if it is possible to use that data from HTML template on the client side and dont't fetch them again with HTTP calls (implementing Angular Universal transfer state in Spartacus app)

I would be very grateful for any advice regarding correct approach (overiding adapters or resolvers or any other solution) for the state transfer implementation in the Spartacus app.

Thank you.

hazoja
  • 11
  • 2

1 Answers1

1

The configured transfer state should work OOTB for some parts of the data, but not for everything. See the source code of cms-store.module.ts, product-store.module.ts and site-context-store.module.ts.

enter image description here

Note that by default the CMS page data is re-loaded in the client, unless you configure RouteLoadStrategy to ONCE in the routing config.

If you find that the Spartacus transfer state is not working correctly, please create a bug ticket in the Spartacus repo and reference it here.

Krzysztof Platis
  • 1,183
  • 5
  • 14