Skip to content

React SDK

The React SDK provides hooks and components for easy integration.

Terminal window
npm install @analyze.swiss/react
import { AnalyzeProvider } from '@analyze.swiss/react';
function App() {
return (
<AnalyzeProvider apiKey="YOUR_API_KEY">
<YourApp />
</AnalyzeProvider>
);
}
import { useAnalyze } from '@analyze.swiss/react';
function SignupButton() {
const { track } = useAnalyze();
return (
<button onClick={() => track('signup_clicked')}>
Sign Up
</button>
);
}
import { useIdentify } from '@analyze.swiss/react';
function UserProfile({ user }) {
const identify = useIdentify();
useEffect(() => {
identify(user.id, {
email: user.email,
name: user.name
});
}, [user]);
}