npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@microsoft/clarity

v1.0.2

Published

An analytics library that uses web page interactions to generate aggregated insights

Readme

@microsoft/clarity

Microsoft Clarity is a comprehensive, free behavioral analytics tool designed to give you in-depth insights into user behavior on your website. With Clarity, you can utilize session replays, heatmaps, insights, and the Clarity Copilot feature, which provides intelligent summaries and actionable insights to help you optimize your site more effectively and drive data-driven decisions.

The Clarity NPM package will help you bring Clarity directly to your website.

Installation

Add this package as a dependency in your project:

npm install @microsoft/clarity

Then import the library in your code:

import Clarity from '@microsoft/clarity';

Initialize Clarity

To activate the Clarity project, Clarity needs to be initialized with the Clarity project ID. To get the Clarity project ID, go to your Clarity project > Settings > Overview.

// Make sure to add your actual project id instead of "yourProjectId".
const projectId = "yourProjectId"

Clarity.init(projectId);

Parameters

  • projectId: String (Required)
    • Description: The ID of the project.

Identify API

Custom identifiers are informational data values about site visitors that are sent to Clarity by your client-side code over its Identify API. They include custom-id, custom-session-id, and custom-page-id and can help you customize the features on your site that requires it.

Clarity.identify("custom-id", "custom-session-id", "custom-page-id", "friendly-name"); // only custom-id is required

Parameters

  • customId: string (Required)
    • Description: The unique identifier for the customer.
  • customSessionId: string (Optional)
    • Description: A custom session identifier.
  • customPageId: string (Optional)
    • Description: A custom page identifier.
  • friendlyName: string (Optional)
    • Description: A friendly name for the customer.

Note

  • Clarity securely hashes the customId on the client before being sent to Clarity servers.
  • For optimal user tracking, the Identify API should be called for each page of the website even if you are not passing a custom-session-id or custom-page-id.

Custom tags API

Clarity offers many predefined ways to filter and analyze website data. However, you might want to track elements specific to your site or user experience. With custom tags, you can apply arbitrary tags to your Clarity session.

Clarity.setTag("key", "value");

Parameters

  • key: string (Required)
    • Description: The key for the tag.
  • value: string | string[] (Required)
    • Description: The value(s) for the tag.

Custom events API

If you prefer to instrument these user actions manually via Clarity APIs, call the event API with the action you'd like to track. When Clarity collects data for this event, it appears with your other Smart events in the Filters, Dashboard, Settings, and Recordings vertical.

Clarity.event("custom-event");

Parameters

event

  • eventName: string (Required)
    • Description: The name of the event.

Cookie consent

If your project is configured to require cookie consent, Clarity uses a unique first-party cookie to track each user with a browser cookie. If cookie consent is required, you must call the consent API to indicate that you have consent from the user to track them using a cookie.

// v2 consent api (recommended)
Clarity.consentV2(); // default value is set to { ad_Storage: 'granted', analytics_Storage: 'granted' }
Clarity.consentV2({ ad_Storage: 'denied', analytics_Storage: 'granted' });

// v1 consent api
Clarity.consent(); // default value is set to true
Clarity.consent(false);

Parameters

v2

  • consentOptions: { ad_Storage: "granted" | "denied"; analytics_Storage: "granted" | "denied" } (Optional)
    • ad_Storage: Consent for storing data related to ads.
    • analytics_Storage: Consent for storing analytics-related data.

v1

  • consent: boolean (Optional)
    • Description: Indicates whether consent is given.

Upgrade session API

You can use the upgrade API to prioritize specific types of sessions for recording. This is useful if you have sessions with specific types of events (such as clicks) that you want to look at or interactions with specific parts of your website (such as a shopping cart).

Clarity.upgrade("reason");

Parameters

upgrade

  • reason: string (Required)
    • Description: The reason for the upgrade.

Useful links