SDK Integration

This document provides steps for integrating your browser with Hackle via the Hackle SDK for Javascript platforms. SDK Integration is a must in order to use the functions we provide.

Step 1: Add Dependencies

Think of this step as importing our SDK into your codebase. To use our Hackle services add the following dependency code and import our SDK.

npm install --save @hackler/javascript-sdk

Step 2: Initialize the SDK

Once you have imported the dependencies, in order to start using the Hackle SDK you must initialize the SDK. During this step, we get the information needed for SDK integration from the Hackle Server and store it in the SDK.

HackleClient is a class that provides methods for using SDK functions.
Here you can pass the SDK key to the createInstance() method to instantiate it.

import * as Hackle from "@hackler/javascript-sdk";

//Enter the SDK Key in the YOUR_BROWSER_SDK_KEY.
const hackleClient = Hackle.createInstance("YOUR_BROWSER_SDK_KEY")
<script src="https://cdn.jsdelivr.net/npm/@hackler/[email protected]/lib/index.browser.umd.min.js"></script>
<script>
  HACKLE_SDK_KEY = "YOUR_BROWSER_SDK_KEY";
  window.hackleClient = Hackle.createInstance(HACKLE_SDK_KEY);
</script>

When HackleClient is instantiated, it gets the necessary information from the Hackle server and stores it in the SDK.
This operation is executed asynchronously and the onReady() method lets you know that the SDK is ready to use.

hackleClient.onReady(() => {
  // SDK ready to use
});

Did this page help you?