Includes field values and metadata about the requested item, including its ID and template.
Outputs placeholders and their renderings in a nested tree structure, representative of the parent/child relationships in the layout. This simplifies the rendering logic in the client significantly.
Serializes the content associated with the rendering. By default, this is the rendering's datasource item.
Renders Sitecore fields to structured JSON based on field type, allowing structured use of field values and metadata (e.g. image alt text).
Includes customizable "context" data useful for rendering (e.g. data from Sitecore.Context such as the current site, user, and editing mode).
Rendered fields with Experience Editor markup for inline editing.
Rendering and placeholder "chromes" from the rendering engine, which allows the Experience Editor to insert editing controls.
Getting the output of the whole layout for the item.
config The name of the Layout Service configuration to use. For JSS, this will usually be jss. More information can be found below on customizing Layout Service configurations.
item The path to the item, relative to the context site's home item or item GUID (ID).
sc_lang The language version of the item you wish to retrieve.
sc_apikey An SSC API Key which has been configured for use with the Layout Service controller (Sitecore.LayoutService.Mvc.Controllers.LayoutServiceController, Sitecore.LayoutService.Mvc). An API Key is required in the query string or sc_apikey HTTP Header.
tracking (optional) Enables/disables analytics tracking for the Layout Service invocation. Default is true. See details below on the Layout Service and Analytics.
Getting the output of a particular placeholder.
This action is useful in special circumstances when your app needs to access a portion of the layout, therefore minimizing the amount of data processed and sent over the wire.
This action accept all the same parameters as the /render action described above, plus one more below.
placeholderName The name of the placeholder to render. The value of this parameter can be retrieved from the layout details in Content Editor. Due to the dynamic placeholders used out of the box for jss, configuration, make sure you use the dynamic placeholder format here.
Consider adding tracking=false if you use this action to avoid extra page visits registered within visit, which will be reflected in xDB.
Other general Sitecore query string parameters will work with the Layout Service as well, such as sc_camp for triggering an analytics campaign.
You should always invoke the Layout Service using a host name which will resolve to the desired Site Context, as Layout Service paths are relative to the site Home item. In addition, the site context is needed for the analytics tracking included in Layout Service calls.
To output the full structured layout of an item, the Layout Service needs to know what placeholders are present on a rendering. Previously, this was not exposed as data on a rendering, rather just through the code of the rendering itself -- e.g. @Html.Sitecore().Placeholder("content"). In order to make these "exposed" placeholders discoverable, the Layout Service adds a new field to the Sitecore rendering definition.
By default, JSS's configuration of the Layout Service assumes that all placeholders other than the root placeholder (usually main) are dynamic placeholders, and will use Sitecore's built-in dynamic placeholder logic to determine the actual placeholder keys to "render."
The Layout Service executes within the Sitecore MVC rendering engine, and thus retains all Sitecore analytics tracking and functionality. This means that if you use the Layout Service for routing in your JSS app, each route change will reflect as a page view in your analytics data. To avoid confusing URLs in your analytics data, the Layout Service will set the resolved item and its path as the tracked item and URL, respectively.
If you don't want analytics tracking for your JSS app, or for particular Layout Service calls, set the tracking parameter to false.
The Sitecore JSS SDK provides an axios-based API to make utilizing the Layout Service easier. The dataApi object is found in the @sitecore-jss\sitecore-jss package but is also exposed via the framework-specific SDKs.