![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
umami-react
Advanced tools
A modern, typed React library for Umami analytics Track page views and events from Client and Server React components with hooks or data attributes.
bun add umami-react
yarn add umami-react
pnpm add umami-react
npm install umami-react
UmamiAnalytics
component and wrap your application with itimport { UmamiAnalytics } from 'umami-react';
interface ProvidersProps {
children: React.ReactNode;
}
export default function Providers() {
return (
<UmamiAnalytics
src="https://analytics.yourapp.com/script.js"
websiteId="your-website-id"
>
{children}
</UmamiAnalytics>
)
}
useTrack
or useIdentify
hook to track page views, events and users.import { useTrack, useIdentify } from 'umami-react';
export default function Home() {
const track = useTrack();
const identify = useIdentify();
useEffect(() => {
track('pageview', { title: 'Home' });
identify('user', { id: '123' });
}, []);
return (
<div>
<h1>Home</h1>
<button type="button" data-umami-event="hero_btn_click" data-umami-event-isbot={false}>
Click me
</button>
</div>
)
}
UmamiAnalytics
propssrc
: The URL of the Umami tracker script. This is the script that will be loaded to track page views and events. You can get this URL from your Umami instance.
websiteId
: The website ID that Umami has provided to track. This is a unique identifier for your website.
autoTrack
: Whether to automatically track page views. If set to true
, the umami-react
library will automatically track page views when the component is mounted. If set to false
, you will need to manually call the track
function to track page views.
hostURL
: By default, Umami will send data to wherever the script is located. You can override this to send data to another location.
domains
: If you want the tracker to only run on specific domains, you can add them to your tracker script. Helps if you are working in a staging/development environment.
tag
: If you want the tracker to collect events under a specific tag.
Events can be filtered in the dashboard by a specific tag.
async
: Whether to load the script asynchronously.
defer
: Whether to defer the script execution.
onLoadError
: Callback that is called when the Umami tracker could not be loaded. This can be useful for debugging.
onLoad
: Callback that is called when the Umami tracker has been loaded. This can be useful for debugging.
children
: The children to render. Children that calls umami-react
functions should be here.
import { UmamiAnalytics } from 'umami-react';
export default function App({ children }) {
return (
<UmamiAnalytics
src="https://analytics.yourapp.com/script.js"
websiteId="your-website-id"
autoTrack={false}
domains={['yourapp.com']}
tag="br"
async
defer
>
{children}
</UmamiAnalytics>
)
}
useTrack
hookuseTrack
is a hook that returns a function to track page views and events. The function takes two arguments: the event type and the optional event data.
const track = useTrack();
track('pageview');
track('btn_signup_click');
track('logout', { expiredToken: true });
useIdentify
hookuseIdentify
is a hook that returns a function to identify users. The function a single argument: the user data.
const identify = useIdentify();
identify({ id: '123', language: navigator.language });
identify({ theme: 'dark', prefersDarkMode: true, prefersReducedMotion: false });
The umami-react
library is open-source software licensed under the MIT.
FAQs
A modern, typed React library for Umami analytics
The npm package umami-react receives a total of 23 weekly downloads. As such, umami-react popularity was classified as not popular.
We found that umami-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.