JavaScript SDK
The @swipelux/onramp-js
package provides a simple way to embed the Swipelux On-Ramp widget into your website using plain JavaScript.
Integration steps
Install the package
The JavaScript Web SDK can be integrated into your project in two different ways.
For projects using modern build tools, we recommend installing the @swipelux/onramp-js
package from npm.
This provides the best experience when working with bundlers like Vite or Webpack, and includes full TypeScript support.
In more traditional websites, you can load the SDK directly from a CDN like jsDelivr using a <script>
tag. This method requires no build tools and works in any supported browser.
To get started, include our JavaScript SDK in your project by adding a <script>
tag to your HTML file's <head>
section.
Once you've installed this, you're ready to set up your project to integrate the Swipelux widget.
Create an empty container for the widget
Before you can initialize the widget, you need to create an empty container for it to be rendered in.
This can be any HTML element, but it's recommended to use a <div>
element with a unique id
attribute to target the element later in the code.
Initialize and mount the widget
Create an instance of SwipeluxWidget
with your widget settings object and call mount()
with the container element we created in the previous step.
This will display the widget on the page.
You're all set!
You've now integrated the Swipelux On-Ramp widget into your website.
Visit your page and confirm that the widget is displayed correctly.
Next steps
We've only covered the basics of how to integrate the Swipelux On-Ramp widget into your website using plain JavaScript.
If you're using a server-side integration and create orders using our REST API, then you should use the orderToken
property in the SwipeluxWidget
constructor to initiate the widget with a prepared order.
To learn more about orderToken
and other supported widget settings, please refer to the Supported widget settings article.