2.0.0 • Public • Published

Speed.js ES Module

Use Speed.js as an ES module.

Note: You must load Speed.js directly from https://js.tryspeed.com. You cannot include it in a bundle or host it yourself. This package is the same as the above link and wraps the global Speed object provided by the Speed.js script as an ES module.

Version 2 is out! If you are still using version 1, we highly recommend you update or use the new version. However, if you wish to use the previous version, please visit this link


Speed JS is an easy-to-use solution for businesses who want to start accepting crypto payments on their platform with a few lines of code.

Create a checkout session to collect payments. It is the easiest way to accept one-time payments with a custom-branded hosted payment page. Accepting cryptocurrency as a payment method will give you access to a whole new market of consumers who are a part of the community.


Use to install the Speed.js module:

npm install @speeddev/speed-js


yarn add @speeddev/speed-js


Import Speed.js

This function returns a newly created Speed object once speed.js is loaded. It takes the same parameters passed when directly initializing a Speed instance.

import { Speed } from "@speeddev/speed-js";

// Speed.js is not initiated until this is called
const speed = new Speed("pk_test_fdrdetxilogwetazubs");

We have placed a random API key in this example. Replace it with your actual publishable API keys to test this code through your Speed account.

For more information on how to use Speed.js, please refer to the Speed.js API reference or learn to accept a payment with Speed.

Manually include the script tag

Manually add the Speed.js script tag to the <head> on your site. When you call Speed with your publishable key, it will use the existing script tag.

<!-- Somewhere in your site's <head> -->
<script src="https://js.tryspeed.com"></script>

Once the script is loaded you can create an object of speed.js by passing a publishable key.

const speed = new Speed("pk_test_fdrdetxilogwetazubs");

Create Checkout Session

To create a checkout session you can call the function of speed.js to create a checkout session by passing a required parameter to it.

  currency: "INR",
  amount: 100,
  successUrl: "https://example.com",
  cancelUrl: "https://example.com",
  successMessage: "Payment Successful!",
  paymentMethods: ["onchain", "lightning"],
  metadata: {
    country: "India",


Below we have all the parameters that you can use to create the checkout session.

Name Type Required Description
currency string true You must specify your preferred base currency (fiat or cryptocurrency) to create a checkout session. A three-lettered ISO-compliant currency name must be used.
amount number true Amount for which you want to create a checkout session
successUrl string false When the payment is successful, you can use this parameter to redirect the customer to your hosted page.
cancelUrl string false This parameter is used to redirect your user to any site you want when they do not proceed with the payment and click the return button.
successMessage string false This is the custom success message that will show after payment successful.
paymentMethods array false We offer both on-chain & lightning network payment options for customers to choose from.
metadata object false To help you gather additional data, this parameter has been added which you can easily add or remove while integrating.

Speed.js Documentation

Package Sidebar


npm i @speeddev/speed-js

Weekly Downloads






Unpacked Size

22.5 kB

Total Files


Last publish


  • dev-sanyam
  • tryspeed