JavaScript SDK V2
sherpa° javascript sdk
Integrate sherpa in a matter of minutes. The sherpa JavaScript SDK provides a convenient wrapper around the sherpa APIs and streamlines the developer experience. Use the SDK to add an Embeddable Element to your web platform.
App Id
When using the SDK to integrate an Embeddable Element (for example, Travel Restrictions Map), you will need an App Id. Please request one from your contact @ sherpa°.
Setup sherpa° SDK
You need to include the sherpa° SDK on your website by adding the script tag to the head
of your HTML file:
<!-- load script -->
<script src="https://sdk.joinsherpa.io/widget.js?appId=APP_ID"></script>
Loading the sherpa° SDK dynamically
If you prefer to load the script asynchronously, you can place the script tag anywhere on your website or load it on-demand. Once the script is loaded, a callback function will be called with a 'loaded' event to indicate that the SDK is ready and a new Embedded Element can be created.
// onSherpaEvent needs to be declared before the script is loaded
function onSherpaEvent(event){
if(event.type === 'sdkLoaded'){
// sdk is ready, create and mount new elements
$sherpa.V2.createElement(....)
}
}
// load the script asynchronous
<script src="https://sdk.joinsherpa.io/widget.js?appId=APP_ID" async></script>
declare onSherpaEvent before the SDK is loaded
Browsers run the code on your page from the top to the bottom. For the sherpa° SDK to work correctly, the javascript code needs to be fully loaded first.
Updated 4 months ago