# Stripe.js reference

This reference documents every object and method available in Stripe’s browser-side JavaScript library, Stripe.js. Use our [React Stripe.js reference](/js/react_stripe_js.md) if you want to add Elements to your React based app. You can use Stripe.js’ APIs to tokenize customer information, collect sensitive payment details using customizable [Stripe Elements](/payments/elements.md), and accept payments with [browser payment APIs](/stripe-js/elements/payment-request-button.md) like Apple Pay and the Payment Request API.

## Including Stripe.js

Include the Stripe.js script on each page of your site—it should always be loaded directly from `https://js.stripe.com`, rather than included in a bundle or hosted yourself. To best leverage Stripe’s advanced fraud functionality, include this script on every page, not just the checkout page. This [allows Stripe to detect suspicious behavior](/disputes/prevention/advanced-fraud-detection.md) that may be indicative of fraud as customers browse your website.

**Using Stripe.js as a module**

We also provide an npm package that makes it easier to load and use Stripe.js as a module. For more information, check out the [project on GitHub](https://github.com/stripe/stripe-js).

**Asynchronous and deferred loading of Stripe.js**

Asynchronous loading of JavaScript is generally recommended, as it can improve the user experience of your site by not blocking DOM rendering during [script loading.](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript#script_loading_strategies) The easiest way to asynchronously load Stripe.js is to use the npm module as described above. It does asynchronous loading by default. You can also load Stripe.js using the `async` or `defer` attribute on the script tag. Note, however, that with asynchronous loading any API calls will have to be made only after the script execution has finished.

**Versioning**

The Stripe.js URL is versioned—we recommend keeping up to date with the latest version. For more information, see the [Stripe.js versioning and support policy](/sdks/stripejs-versioning.md).

### Example

```javascript
// Including Stripe.js
```

## Initializing Stripe.js

`Stripe(publishableKey: string, options?: object)`

Use `Stripe(publishableKey, options?)` to create an instance of the **Stripe object**. The Stripe object is your entrypoint to the rest of the Stripe.js SDK. Your Stripe publishable [API key](/keys.md) is required when calling this function, as it identifies your website to Stripe. We've prefilled the example with a sample [test API key](/keys.md). Don’t submit any personally identifiable information in requests made with this key. To create a Stripe object using your account, replace the sample API key with your actual API key or [sign in](/login.md?redirect=%2Fdocs%2Fjs%2Finitializing). When you’re ready to accept live payments, replace the test key with your live key in production. Learn more about how API keys work in [test mode and live mode](/dashboard.md#viewing-test-data).

When you use the same publishable API key and options, create and share a single instance of the Stripe object. Creating multiple instances might lead to performance issues.

*   `publishableKey`
    Your publishable key.
*   `options`
    Initialization options.
*   `stripeAccount`
    For usage with [Connect](/connect.md) only. Specifying a connected account ID (e.g., `acct_24BFMpJ1svR5A89k`) allows you to perform actions on behalf of that account.
*   `apiVersion`
    Override your account's [API version](/api/versioning.md). **This option is only available on Stripe.js v3.** For versions after `v3` such as `acacia`, the API version is [pinned to the Stripe.js version](/sdks/stripejs-versioning#compatibility-with-api-versions).
*   `locale`
    A [locale](/js/appendix/supported_locales.md) used to globally configure localization in Stripe.js. Setting the locale here will localize error strings for all Stripe.js methods. It will also configure the locale for [Elements](/js/element/address_element.md#element_mount). Default is `auto` (Stripe detects the locale of the browser).
*   `developerTools`
    Stripe.js developer tooling options.
*   `assistant`
    Stripe Elements sandbox assistant options.
*   `enabled`
    Set to `false` to disable the sandbox assistant UI. Defaults to `true` when using [Elements with the Checkout Sessions API](/checkout/custom/quickstart.md) or when using [Elements with the Payment Intents API](/payments/quickstart.md) on