@trackier/react-websdk
is a lightweight wrapper for the Trackier Web SDK, making it easier to integrate with React applications.
To install the package via npm, run:
npm install @trackier/react-websdk
Import the SDK and initialize it in your application:
import TrackierWebSDK from "@trackier/react-websdk";
import { useEffect } from "react";
function App() {
useEffect(() => {
TrackierWebSDK.init("localStorage", { trackingId: "your-tracking-id" });
}, []);
const handleClick = () => {
const trackingToken = TrackierWebSDK.getTrackingToken();
console.log(trackingToken);
};
return (
<div>
<button onClick={handleClick}>Get Tracking Token</button>
</div>
);
}
export default App;
- Git
- A clone of this repository on your local machine
Clone the repository:
git clone https://github.com/trackier/react-trackier-websdk.git
Go into the project root:
cd react-trackier-websdk
Install npm packages:
npm install
For development, you can run the project locally:
npm run build
If you want to test the SDK locally in another project, use npm link
:
-
In the SDK project directory, run:
npm link
-
In your React app where you want to test the SDK, run:
npm link @trackier/react-websdk