Provider to wrap your app with
import {CommerceApiProvider} from '@salesforce/commerce-sdk-react'
const App = ({children}) => {
return (
<CommerceApiProvider
clientId="12345678-1234-1234-1234-123412341234"
organizationId="f_ecom_aaaa_001"
proxy="localhost:3000/mobify/proxy/api"
redirectURI="localhost:3000/callback"
siteId="RefArch"
shortCode="12345678"
locale="en-US"
enablePWAKitPrivateClient={true}
currency="USD"
logger={logger}
>
{children}
</CommerceApiProvider>
)
}
export default App
Note: The provider can enable SLAS Private Client mode in 2 ways.
enablePWAKitPrivateClient
sets commerce-sdk-react to work with the PWA proxy
/mobify/slas/private
to set the private client secret. PWA users should use
this option.
Non-PWA Kit users can enable private client mode by passing in a client secret directly to the provider. However, be careful when doing this as you will have to make sure the secret is not unexpectedly exposed to the client.
hybridAuthEnabled
is an optional flag that indicates the current Site has Hybrid Auth enabled.
This drives the behavior of the clearECOMSession
method. If hybridAuthEnabled
is true,
the clearECOMSession
method will not be called. This makes sure the session-bridged dwsid, received from /oauth2/token
call
on shopper login is NOT cleared and can be used to maintain the server affinity.
hybridAuthEnabled
flag can also be used to drive other Hybrid Auth specific behaviors in the future.
Note: hybridAuthEnabled
should NOT be set to true for hybrid storefronts using Plugin SLAS as we need the dwsid to be deleted
to force session-bridging on SFRA as in this case, the oauth2/token
call does not return a dwsid.
Initialize a set of Commerce API clients and make it available to all of descendant components