Migrating from window.ReCharge to the Recharge JavaScript SDK
Recharge is depreciating the window.ReCharge global object to improve customer portal performance and align merchants with our modern, secure JavaScript SDK.
This guide outlines feature-by-feature migration paths, and maps all legacy window.ReCharge APIs to their SDK equivalents.
TipIf your use case isn’t covered in this guide, contact the Recharge Support team for additional assistance.
Getting Started
Initialize the SDK
initRecharge(options)Authentication & Session Handling
- Login via Shopify App Proxy:
loginShopifyAppProxy - Fetch store/customer context:
getStoreSettingsgetCustomer
See Script Setup in the SDK docs for more information.
Subscriptions
Legacy
window.ReCharge.subscriptions
SDK equivalents
listSubscriptions(params: SubscriptionListParams)getSubscription(options: GetSubscriptionOptions)createSubscriptionupdateSubscriptioncancelSubscriptionactivateSubscriptionupdateSubscriptions (bulk)updateSubscriptionChargeDateupdateSubscriptionAddress
Common migrations
Active subscriptions
Legacy
window.ReCharge.subscriptions.filter(s => s.status === 'ACTIVE');SDK
listSubscriptions({ status: 'ACTIVE' })
// or list + filter if status filter is unsupportedFind a subscription ID
Legacy
window.ReCharge.subscriptions.find(...)SDK
getSubscription({ id })Bulk edits
Legacy
Manually iterating over subscriptions in window.ReCharge
SDK
updateSubscriptions({ subscriptions: [...] })Charges
Legacy
window.ReCharge.charges- Deriving
subscription_idfrom:window.ReCharge.charges[0].line_items[0].subscription_id
SDK equivalents
listCharges(params: ChargeListParams)getCharge(options: GetChargeOptions)processChargeskipChargeunskipChargeskipSubscriptionChargeskipFutureChargeskipGiftSubscriptionChargedelayOrder
Common migrations
Replace manual caching
Legacy
window.ReCharge.charges = ...SDK
Use your own helper and store:
listCharges({ status: 'queued' })Resolve subscription from charge
Legacy
const id = window.ReCharge?.charges?.[0]?.line_items?.[0]?.subscription_id;SDK
const charge = getCharge({ id });
const subscriptionId = charge.line_items[0].subscription_id;
getSubscription({ id: subscriptionId });Customer
Legacy
window.ReCharge.customer.* (email, name, hash, timestamps, etc.)
SDK equivalents
getCustomerupdateCustomer
Common migrations
Get customer email
Legacy
window.ReCharge?.customer?.emailSDK
const customer = getCustomer();
customer.email;Addresses
Legacy
window.ReCharge.addresses
SDK equivalents
listAddressesgetAddresscreateAddressupdateAddressdeleteAddressmergeAddresses
Common migrations
Replace passive waiting/interception with explicit fetching
Legacy
Relying on automatic updates to window.ReCharge.addresses
SDK
const result = listAddresses();
applyRestrictions(result.addresses);
// re-run whenever you change addresses or detect updatesOnetimes, Orders, Payments, Metafields
Onetimes
listOnetimesgetOnetimecreateOnetimeupdateOnetime- deleteOnetime
Orders
listOrdersgetOrderdelayOrder(where applicable)
Payment Methods
listPaymentMethodsgetPaymentMethodcreatePaymentMethodupdatePaymentMethod
Credits, Discounts, Gifting
Credits
getCreditSummarylistCreditAccountssetApplyCreditsToNextCharge(apply credit)
Discounts
applyDiscountToAddressremoveDiscountsFromAddressapplyDiscountToChargeremoveDiscountsFromCharge
Gifting
listGiftPurchasesgetGiftPurchasegetGiftRedemptionLandingPageURL
Auth/Session and token replacement
Legacy tokens
window.ReCharge.token(used in iframes and URLs)
SDK replacements
- Use the login/session flows instead of exposing tokens in the DOM
- For portal links/access, use:
getCustomerPortalAccess()to return scoped, time-bound access details.
Common migrations
Token in iframe URL
Legacy
...&token=${window.ReCharge.token}SDK
getCustomerPortalAccess()
Updated about 15 hours ago
