JSS Layout API
Sitecore JavaScript Rendering SDK (JSS) provides an API to help you retrieve information about layouts from Sitecore.
When using JSS, you can get layout data from several endpoints, without worrying about data fetching implementation details. The JSS Layout API abstracts data fetching implementation details into services, clients, and data fetchers for REST and GraphQL endpoints. See some usage examples.
Sitecore endpoints for layout data
There are several options for fetching layout information from Sitecore:
-
Call the REST Layout Service endpoint provided by Sitecore Headless Services.
-
Query the Sitecore Edge Preview GraphQL endpoint provided by Headless Services. Sitecore Edge Preview GraphQL API implements a GraphQL server on top of Sitecore. The Sitecore GraphQL schema mirrors the Experience Edge schema.
-
Query the GraphQL endpoint provided by Sitecore Experience Edge for XM. Sitecore Experience Edge for XM has a read-only GraphQL schema to accommodate common front-end use cases for headless Sitecore development. If you are building a very large website, you might have to enable retries for requests to the XM Cloud Experience Edge GraphQL endpoint for the build process to succeed.
You can choose whether to use REST or GraphQL endpoints by creating your JSS application with the --fetchWith REST
parameter or the --fetchWith GraphQL
parameter.