Is it possible to decouple the use of the LayoutService from all of the Routing code and use it independently? We are upgrading an AngularJS application to Angular and have incorporated JSS but are not yet ready to commit to new Angular routing so would just like to have the ability to get JSS/Sitecore data within our new components. I don't want to make changes to the code that could break us with future upgrades to the Sitecore JSS libraries.

Any suggestions would be much appreciated.

1 Answer 1


Absolutely possible to use without routing. The layout service is a simple REST API at its core, and it does not care if it's invoked from a router or not.

The sample app's jss-context.service.ts shows the REST call being made. The sitecore-jss-angular package's LayoutService type uses the angular HttpClient to make the call.

If you think you'll need routing later, it may be easier in the long term to keep the router around and just use a single route for the moment.

JSS apps must support server-side rendering to be usable in the Experience Editor, which means your app will need to be TransferState-aware like the sample is. During SSR, the route data is passed into the renderView() function directly and is not acquired via REST.

  • So is the general answer here suggesting that implementing only the REST API (LayoutService) approach could hamper how users make changes to the site? (i.e. they will not be able to use the Experience Editor?) They would only be able to change Content Tree items in Sitecore?
    – Toby Nunn
    Nov 7, 2018 at 17:05
  • 1
    Without routing on the client, EE support can become significantly more difficult. Sitecore's server-side routing needs to be able to match the client-side routing defined in JS. If the app has only one 'page' then EE is fine without routing. But if it has multiple views, or authors can add views, you may need routing or other customizations to use EE effectively.
    – Kam Figy
    Nov 8, 2018 at 19:00

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.