Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jitsu/jitsu-react

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jitsu/jitsu-react - npm Package Compare versions

Comparing version 1.5.1 to 1.6.1

4

package.json
{
"name": "@jitsu/jitsu-react",
"version": "1.5.1",
"version": "1.6.1",
"description": "",

@@ -14,3 +14,3 @@ "license": "MIT",

"dependencies": {
"@jitsu/js": "1.5.1"
"@jitsu/js": "1.6.1"
},

@@ -17,0 +17,0 @@ "peerDependencies": {

@@ -14,40 +14,2 @@ # jitsu-react

To setup Jitsu-React library you need to add `JitsuProvider` component close to the root level of your app:
```tsx
import React from "react";
import { JitsuProvider } from "@jitsu/jitsu-react";
export default function App() {
return <JitsuProvider options={{ host: "https://<id>.d.jitsu.com" }}>
<Page />
</JitsuProvider>;
}
```
Then use `useJitsu` hook in components where you want to track events.
```tsx
import * as React from "react";
import { useJitsu } from "@jitsu/jitsu-react";
import { useEffect } from "react";
export default function Page() {
const { analytics } = useJitsu();
useEffect(() => {
// Track page view
analytics.track("event", { prop: "value" });
}, [location]);
return (
<div>
<button onClick={() => analytics.track("button-click")}>Click me!</button>
</div>
);
}
```
As `location` you should use an value that changes on every navigation. Examples:
* React Router: `useLocationHook()`
* Next.js: `const rounter = useRouter()`; then `router.asPath`
* Others: `[window.location.pathname, window.location.search, window.location.hash]`
**Please read a documentation on [Jitsu Docs](https://docs.jitsu.com/sending-data/react)**
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc