Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1,359 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ข Hey there, Salesforce Commerce Cloud community!

Weโ€™re excited to hear your thoughts on your developer experience with PWA Kit and the Composable Storefront generally! Your feedback is incredibly valuable in helping us guide our roadmap and improve our offering.

๐Ÿ“‹ Take our quick survey here: Survey

Feel free to share this survey link with your colleagues, partners, or anyone who has experience with PWA Kit. Your input will help us shape the future of our development tools.

Thank you for being a part of our community and for your continuous support! ๐Ÿ™Œ

โš ๏ธ Planned API Changes โš ๏ธ

Shopper Context

Starting July 31st 2024, all endpoints in the Shopper context API will require the siteId parameter for new customers. This field is marked as optional for backward compatibility and will be changed to mandatory tentatively by January 2025. You can read more about the planned change here in the notes section.

Shopper Login (SLAS)

SLAS will soon require new tenants to pass channel_id as an argument for retrieving guest access tokens. You can read more about the planned change here.

Please be aware that existing tenants are on a temporary allow list and will see no immediate disruption to service. We do ask that all users seek to adhere to the channel_id requirement before the end of August to enhance your security posture before the holiday peak season.

Summary of Changes for PWA Kit v2

To comply with the planned API changes effective July 31st, 2024, you need to update your PWA Kit v2 projects. These changes involve adding the channel_id parameter for Shopper Login and optionally scoping your local storage keys and cookie names with the siteId prefix if your site uses multisite.

1. Update auth.js to Include channel_id in Calls to Shopper Login

Add the channel_id parameter in the appropriate functions for obtaining tokens.

Example Changes:
// In the Auth class, add channel_id to the data in _loginAsGuest method
channel_id: this._config.parameters.siteId

// In the refreshToken method, add channel_id to the data
data.append('channel_id', this._config.parameters.siteId)

2. Scope Local Storage Keys and Cookie Names per Site for Multisite Projects

For customers using multiple site IDs, it is recommended to scope your local storage keys and cookie names per site to avoid conflicts. This ensures that tokens from different sites (e.g., RefArch and RefArchGlobal) are not incorrectly used across sites.

Example Changes:
// Add siteId parameter in LocalStorage and CookieStorage constructors
constructor(siteId, ...args) {
    super(args)
    if (typeof window === 'undefined') {
        throw new Error('LocalStorage is not available in the current environment.')
    }
    this.siteId = siteId
}

// Create storage key with siteId prefix
createStorageKey(key) {
    return `${this.siteId}_${key}`
}

// Set item in local storage with siteId prefix
set(key, value) {
    window.localStorage.setItem(this.createStorageKey(key), value)
}

// Get item from local storage with siteId prefix
get(key) {
    return window.localStorage.getItem(this.createStorageKey(key))
}

// Delete item from local storage with siteId prefix
delete(key) {
    window.localStorage.removeItem(this.createStorageKey(key))
}

// Similar changes for CookieStorage

Full example of the changes in the auth.js file: https://github.com/SalesforceCommerceCloud/pwa-kit/compare/949b8b3b7...534dab260

Important Note:

Implementing the siteId prefix for local storage keys and cookie names will effectively log out any existing customer sessions on the site. This includes registered logins and baskets for all users.

Recommendation:

  • Established sites that do not need this change should avoid implementing it to prevent logging out existing users.
  • If a project decides to implement this change, be aware that the PWA will now look for tokens under a different cookie name, causing all existing users to be logged out.

The Progressive Web App (PWA) Kit

npm License Checks npm

๐Ÿ“– Read Docs | ๐Ÿ–๏ธ View Demo | ๐Ÿš€ Deploy | โž• Contribute

The PWA Kit is a storefront technology for headless commerce using Salesforce Commerce APIs and React. It provides front-end developers with a more flexible and agile approach to build and maintain modern shopping experiences.

pwa-kit banner


๐Ÿ„ Get Started

Requirements

  • Node 18, 20, 22, or 24
  • npm 9 or later

Create Your First Project

npx pwa-kit-create-app

Enter your sandbox configuration.

Run the Project Locally

npm start

Deploy to Managed Runtime

npm run push -- -m "Message to help you recognize this bundle"

Important: Access to the Runtime Admin application is required to deploy bundles. To learn more, read our guide to Push and Deploy Bundles.

๐ŸŒ Localization

See the Localization README.md for important setup instructions for localization.

โš ๏ธ License Information

The PWA Kit is licensed under a BSD 3-Clause license. See the license for details.

โž• Contribute

Your contributions are welcome! Refer to the CONTRIBUTING guide to get started. If you like pwa-kit, consider adding a โญ on the GitHub Repo. It helps other people discover PWA Kit!

๐Ÿ“– Documentation

The full documentation for PWA Kit and Managed Runtime is hosted on the Salesforce Developers portal.

Useful Links:

๐Ÿ”ฎ Forward-Looking Statements

This repository may contain forward-looking statements that involve risks, uncertainties, and assumptions. For more information, see STATEMENTS

About

React-based JavaScript frontend framework to create a progressive web app (PWA) storefront for Salesforce B2C Commerce.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

359 stars

Watchers

25 watching

Forks

Releases

Used by

Contributors

Languages