Skip to main content

Migrating loginCustomerPortal

If your code calls loginCustomerPortal to get a session inside the Recharge Customer Portal, upgrade the SDK to version 2.8.0 or later.

warning

Versions of the SDK prior to 2.8.0 are deprecated for loginCustomerPortal and will stop working inside the Customer Portal in the near future. Upgrade before then to avoid customers losing access to your portal features.

What changes​

Nothing in your code needs to change. loginCustomerPortal keeps the same signature and returns the same session:

const session = await recharge.auth.loginCustomerPortal();
// session => { apiToken: '...', customerId: 123456 }

The only material changes between older versions and 2.8.0 are to Node support and types:

  • Node support. Node versions before 22 are no longer supported (dropped in 2.0.0). This only affects you if you install the npm package and build or run it with an older Node version. Code loaded in the browser from the CDN is unaffected.
  • Type updates. If you use TypeScript, some types have gained fields or had their nullability corrected to match the API, which can surface new type errors at compile time.

Upgrading​

Update the version in the script URL. If your script tag has an integrity attribute, replace it with the hash for the new version too, since each version has its own hash.

Before:

<script src="https://static.rechargecdn.com/assets/storefront/recharge-client-1.85.0.min.js"></script>

After:

<script
src="https://static.rechargecdn.com/assets/storefront/recharge-client-2.10.0.min.js"
integrity="sha384-hvrfm4H6UY39qeESB2DwXCjwo/gUttt5rLl+NhRUlVnQrqAQKz0xFClfjLK2N9vk"
crossorigin="anonymous"
></script>

After upgrading, load a Customer Portal page and confirm loginCustomerPortal still returns a session.