WidgetsProvider
The WidgetsProvider is the root provider of a React application integrated with Sitecore Discover platform using Discover JS SDK. It allows the use of SDK query hooks in its inner components, sets a cookie, and authenticates.
Cookie
Cookie
The JS SDK sets a cookie at the domain level in a visitor's browser because most of Discover customers share cookies across subdomains. If your domain is a subdomain of top-level or apex domain that restricts cookies, you need to set the value for publicSuffix to true.
The default value of publicSuffix is false.
Authentication
Authentication
For authentication, you must add credential attributes to the WidgetsProvider component. The attributes depend on how your domain is set up with Discover.
To authenticate:
-
Use your
apiDomainwhen Discoverhas been set up as a subdomain. -
Use your
apiKeyanduseTokenwhen Discoverhas not been set up as a subdomain.
Import path
Import path
Example
Example
The following code block shows the WidgetsProvider component with credentials for authentication when your domain is not set up with Discover.
In the following code block, publicSuffix has been set to true because the top-level domain of this implementation restricts cookies.
header_ps and footer_rec appear on all pages according to the configuration.