Configure a Hybrid Storefront with Hybrid Auth (PWA Kit)
Starting with B2C Commerce version 25.3, hybrid authentication (Hybrid Auth) replaces Plugin SLAS. Hybrid Auth keeps the SFRA/SiteGenesis session (dwsid) and SLAS authorization (JWT) synchronized across a storefront that spans PWA Kit (Composable Storefront) and platform-rendered routes.
This guide covers the PWA Kit / Composable Storefront implementation path on PWA Kit v3. It’s the path for new Hybrid Auth implementations—new customers must start on PWA Kit v3.
For the shared, architecture-neutral setup (Business Manager Hybrid Auth settings, SLAS session bridging, Shopper Context, Do-Not-Track synchronization, and basket merge), see Shared Hybrid Auth Setup.
Make sure the SLAS client used for Hybrid Auth includes the sfcc.session_bridge scope.
Step 2: Enable hybridAuthEnabled in the _app-config Component
In app/components/_app-config/index.jsx (or overrides/app/components/_app-config/index.jsx if you use template extensibility), find the CommerceApiProvider component and uncomment the hybridAuthEnabled prop:
Do not set this prop for hybrid storefronts that still use Plugin SLAS. Enable it only for sites that use Hybrid Auth.
Step 3: Update PWA Kit Routes
By default, PWA Kit uses the History API for navigation. When a shopper clicks a link made with a React Router component, it triggers a soft navigation to the component matching the path in app/routes.jsx. To link to a non-PWA Kit page (one powered by SFRA, for example), remove any route matching that URL pathname from app/routes.jsx.
If your PWA Kit project was generated with version 3.x of the Retail React App template using template extensibility, override the overrides/app/routes.jsx file to filter out links to non-PWA Kit pages using JavaScript. For an example override that filters out /cart and /checkout, see this public gist.
Update the PWA catch-all route (/*) in app/routes.jsx. In this example, the PWA <PageNotFound /> component is replaced with a redirect to the default origin:
Step 4: Handle Cookie Responses in the Client Browser
As part of Hybrid Auth, SLAS token calls include the dwsid in the Set-Cookie response header. Make sure the Set-Cookie headers from SLAS API calls are respected and the cookies are set in the browser.
If you use the Commerce Cloud React SDK with the Composable Storefront, this cookie handling is done for you with PWA Kit v3.9 and later. If your site uses commerce-sdk-react, upgrade to @salesforce/commerce-sdk-react@4.0.0 or later.
Note
Step 5: Enable Cookies on Managed Runtime
When Hybrid Auth is enabled, SLAS /oauth2/token requests contain a session-bridged dwsid using the Set-Cookie header in the response. In Managed Runtime, enable cookie passthrough:
Scroll back to the Advanced section and select Update.
Wait for your storefront bundle to redeploy.
Step 6: Configure eCDN Origin Routing
Route top-of-funnel pages (home /, category /category, product /product) to your PWA Kit storefront on Managed Runtime (MRT), and route transactional routes (such as /cart and /checkout) to SFRA/SiteGenesis.
Set Up Hybrid on On-Demand Sandbox (ODS) Instances Using eCDN
Applies to: PWA Kit
On-demand sandbox (ODS) instances include an embedded CDN (eCDN), so configure hybrid routing on ODS the same way you do on a Primary Instance Group (PIG) instance—through the eCDN UI in Business Manager—rather than with the local hybrid proxy. This lets you validate hybrid behavior in a deployed environment that mirrors production routing.
Deploy your PWA Kit bundle to a Managed Runtime environment connected to the ODS instance.
Configure eCDN origin routing rules for the ODS zone using the Business Manager UI. Route top-of-funnel pages (home, category, product, search) to Managed Runtime, and keep transactional routes (such as /cart and /checkout) on SFRA/SiteGenesis. For the UI steps, see CDN Routing Rules for Hybrid Implementations.
Use eCDN—not the hybrid proxy—on ODS instances. Reserve the hybrid proxy for local development on localhost.
Note
Set Up Hybrid Locally for Local Development
Applies to: PWA Kit
For local development on localhost, eCDN isn’t available, so use a reverse proxy instead. The PWA Kit hybrid proxy feature is available starting in PWA Kit v3.14 in the pwa-kit-runtime package.
Enable hybrid proxy for local development only. On PIG and ODS instances, use eCDN to direct requests to the PWA Kit Composable Storefront or SFRA/SiteGenesis store. Don’t enable hybrid proxy on PIG or ODS instances: because hybrid proxy sets localAllowCookies: true, it can cause security issues on deployed instances.
Follow these steps to enable hybrid proxy locally.
Upgrade the pwa-kit-runtime package dependency to v3.14.0 or later.
Configure the hybridProxy value in your Composable Storefront ssr.js for a server-side reverse proxy:
localAllowCookies: true
hybridProxy.enabled: true
hybridProxy.sfccOrigin: [your SFCC store]
Update default.js to configure client-side routing:
Update app.commerceAPI.parameters to point to the correct Commerce API SIG instance.
Add app.enableHybrid: true so that you can toggle hybrid mode on and off.
In app/components/_app-config/index.jsx, uncomment hybridAuthEnabled (see Step 2). Don’t set this flag for hybrid storefronts that still use Plugin SLAS.
Update app/routes.jsx to exclude routes from PWA Kit so that the matching pages render on SFRA/SiteGenesis. This example removes the /cart and /checkout routes from the PWA Kit store and uses the catch-all * route to trigger server-side rendering of the proxied SFRA/SiteGenesis cart and checkout pages. For reference, see this public gist.
1// Remove SFRA/SiteGenesis routes from PWA Kit2const ecomRoutes = ['/cart', '/checkout', '*']34const hybridRoutes = [5 ...routes.filter((route)=> !ecomRoutes.includes(route.path)),6{7 path: '*',8 component: withRouter((props)=>{9 const config = getConfig()10 const{location} = props11 const urlParams = new URLSearchParams(location.search)12 const{site} = useMultiSite()13 const siteId = site && site.id ? site.id : config?.app?.defaultSite1415 if(typeof window !== 'undefined'){16 useEffect(()=>{17 const newURL = new URL(window.location)18 if(!urlParams.has('redirected')){19 newURL.searchParams.append('redirected', '1')20 newURL.pathname = `/s/${siteId}/${window.location.pathname21 .split('/')22 .slice(2)23 .join('/')}`24 window.location.replace(newURL)25}26}, [window.location.href])27}2829 if(urlParams.has('redirected')){30 return<PageNotFound{...props} />31}32 return null33})34}35]3637export default()=>{38 const config = getConfig()39 // Use these routes only in hybrid mode; otherwise use the defaults.40 // This is driven by the config and environment variables.41 const routesToConfigure = config.app.enableHybrid ? hybridRoutes : routes42 return configureRoutes(routesToConfigure, config, {43 ignoredRoutes:['/callback', '*']44})45}
Go to your storefront using the vanity domain configured in eCDN.
Navigate to a page on SFRA/SiteGenesis.
Open browser Developer Tools and inspect cookies. Confirm these cookies are set:
cc-nx-g_{Site_ID}: Guest refresh token
dwsid: B2C Commerce session ID
usid: SLAS customer ID
cc-at_{Site_ID}: SLAS access token (appears only when the user lands on an SFRA page; not seen when navigating from a PWA Kit page to an SFRA page)
Navigate to any PWA Kit page and verify:
cc-nx-g_{SiteID} is unchanged.
dwsid is unchanged.
usid_{SiteID} is unchanged.
cc-at_{SiteID} is no longer present, because PWA Kit consumes it and moves the access token to localStorage. Confirm the accesstoken{SiteID} value in localStorage matches the original cc-at_{SiteID} cookie.
In Developer Tools, switch to the Network tab.
Add an item to the cart on PWA Kit.
Inspect the SCAPI Add to Cart request. In Request Headers, confirm the sfdc_dwsid header is set to the dwsid cookie value. This header is required to keep hybrid storefront behavior stable at production scale when traffic is distributed across multiple app servers. If you’re not using PWA Kit, set this header from your headless application whenever the dwsid cookie is available.
You might observe a 302 redirect if a session has expired (while retaining a valid refresh token in the cc-nx* or cc-nx-g* cookies) or if a refresh token is invalid. This is expected. Make sure your implementation follows these redirects.
Note
Hybrid Auth Feature Support Matrix
The following table compares PWA Kit feature support for Plugin SLAS versus Hybrid Auth.
Feature Name
Supported in PWA Kit w. Plugin SLAS
Supported in PWA Kit w. Hybrid Auth
Notes
SiteGenesis
N
Y
Third Party IDPs and Social Login
N
Y
Third-party IDP: Starting with B2C Commerce version 25.8, hybrid auth supports third-party IDP and Social Login, but you must perform all interactions with a third-party IDP using SLAS. Configure OAuth2 providers in SLAS Admin instead of Business Manager and add a redirect URI in Hybrid Auth Settings.
Social Login: Starting with B2C Commerce version 25.8, you must perform all logins using SLAS.
Salesforce recommends that you enable Shopper Context for Hybrid Authentication as it is the only way personalization data is made available for APIs. See the Shopper Context documentation.
Geolocation-based personalization must be synchronized between Shopper Context and SFRA/SiteGenesis. See Step 7: Set Shopper Context.
Note: The Script API for Shopper Context is available for geolocation-based personalization.
Controller exclusion
Y
N
In Hybrid Auth, there is no need to exclude any controllers.
Cookie setting customization
Y, via customization
N/A
In Hybrid Auth, unlike Plugin SLAS, you no longer have access to the cookie object and can no longer override cookie settings.
Agent/Order On Behalf Of (OOBO)
N
Y
Starting with B2C Commerce version 26.1, Agent/OOBO is supported out of the box in Hybrid Auth with PWA Kit when using the Customer Service Center in Business Manager. If your site uses a third-party cartridge for Agent/OOBO, make sure that you perform testing in a local environment before deploying to your live site.