| [ Web Proxy ] |
| Viewing: https://storefront.getrecharge.com/client/docs/getting_started/script_setup/ | [Back] [Original] |
This library can be used with JavaScript applications in both server and client aspects.
Add the recharge-sdk to your page:
<head>
<script src="https://static.rechargecdn.com/assets/storefront/recharge-client-1.91.1.min.js"></script>
</head>
This will add a recharge global to the window that can be used throughout your page.
To initialize the JavaScript SDK you call initRecharge and pass the following arguments:
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.
recharge.init({
storeIdentifier: 'storeIdentifier', // On Shopify this should be your myshopify.com domain
// required for Storefront API access
storefrontAccessToken: 'storefrontAccessToken',
appName: 'appName',
appVersion: '1.0.0',
loginRetryFn: () => {
return recharge.auth.loginShopifyAppProxy().then(session => {
// do anything you want with the session here
// return session
return session;
});
},
});
| Web Proxy Viewer | New URL | Original Page |