🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@hackler/react-sdk

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hackler/react-sdk

React SDK for Hackle

11.43.0
latest
78

Supply Chain Security

100

Vulnerability

89

Quality

91

Maintenance

100

License

Version published
Maintainers
1
Created

Hackle React SDK

Install

npm install @hackler/react-sdk --save
yarn add @hackler/react-sdk

Usage

initialize

import { createInstance, HackleProvider } from "@hackler/react-sdk";

const hackleClient = createInstance("YOUR_SDK_KEY")
const user = {
  id: "ae2182e0", 
  properties: {
    app_version: "1.0.1",
    age: 23,
    paying_customer: true
  } 
}
ReactDOM.render(
  <HackleProvider hackleClient={hackleClient} user={user} timeout={1000}>
    <YourApp />
  </HackleProvider>,
  document.getElementById('root')
);

Decide the variation

function App() {
  return (
    <HackleExperiment experimentKey={42}>
      <HackleVariation variation={"A"}>
        <OldBlueButton />
      </HackleVariation>
      <HackleVariation variation={"B"}>
        <NewRedButton />
      </HackleVariation>
    </HackleExperiment>
  )
}

Records the event

const track = useTrack()
const event = {
  key: "purchase",
  value: 5000,
  properties: {
    first_paying: false,
    item_count: 5
  }
}

<button onClick={() => track(event)}>Purchase</button>

FAQs

Package last updated on 29 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts