Skip to main content

Script Setup

This library can be used with JavaScript applications in both server and client aspects.


Add the recharge-sdk to your page:

<script src=""></script>

This will add a recharge global to the window that can be used throughout your page.

Initialization v1.0.0 Types

To initialize the JavaScript SDK you call initRecharge and pass the following arguments:

  • storeIdentifier - optional when JavaScript SDK is used within Shopify or Recharge hosted environments, required for headless usage. On Shopify this should be your domain.
  • storefrontAccessToken - optional, but required when using the API functions (see API for additional details)
  • loginRetryFn - optional, middleware function that should return a Session, called when API functions return a 401. This function allows your app to refetch a session, store it by whatever means your app uses for future calls, then return it so the call that failed can be retried.

Access to the storefront API functions require SDK to be initialized with a Recharge storefrontAccessToken - this token can be created via the merchant-admin where you manage your API tokens. Please make sure that the created token is of type Storefront. You can verify you have created the correct token by double checking it starts with strfnt.

storeIdentifier: 'storeIdentifier', // On Shopify this should be your domain
// required for Storefront API access
storefrontAccessToken: 'storefrontAccessToken',
loginRetryFn: () => {
return recharge.auth.loginShopifyAppProxy().then(session => {
// store recharge session
return session;