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 🙏

© 2026 – Pkg Stats / Ryan Hefner

anonymous-user-id

v1.1.0

Published

[![npm](https://img.shields.io/npm/v/anonymous-user-id)](https://www.npmjs.com/package/anonymous-user-id) [![node-current](https://img.shields.io/node/v/anonymous-user-id)](package.json) [![CI](https://github.com/omegavesko/anonymous-user-id/actions/workf

Readme

anonymous-user-id

npm node-current CI GitHub

anonymous-user-id is a JavaScript library that allows you to anonymously identify unique users on your website without requiring them to store (and consent to) a tracking cookie. Instead, we generate a unique ID for each user based on information that can be pulled out of a regular HTTP request, mainly the source IP address and User-Agent header.

The method we use to do this is heavily inspired by Plausible Analytics, with BLAKE2s as the hash function.

Supported Algorithms

  • hash(salt + domain + ip + user_agent) - This is the same algorithm used by Plausible Analytics. It relies on a salt you need to rotate at least once a day, preventing you (or anyone else) from tracking the actions of a single user for longer than the lifespan of a single salt.

  • hash(hash(secret + date) + domain + ip + user_agent) - This is a modified (and less secure) variant of the original algorithm, meant for apps that can't reliably keep state (such as serverless functions), preventing them from storing a salt. Instead, we generate the salt from a long-lived secret (which you can set as e.g. an environment variable) and the current date.

Getting Started

Prerequisites

  • Node >= 10 (if using in Node)

Installing

npm:

npm i anonymous-user-id

yarn:

yarn add anonymous-user-id

Usage

For each algorithm this package supports, it exports a function you can use to generate an ID with it.

  • getAnonymousUserId(salt: string, request: RequestDetails)

    • implements hash(salt + domain + ip + user_agent)
  • getAnonymousUserIdWithSecret(secret: string, request: RequestDetails)

    • implements hash(hash(secret + date) + domain + ip + user_agent)

Example

import {
  getAnonymousUserId,
  getAnonymousUserIdWithSecret,
} from 'anonymous-user-id';

const requestDetails = {
  domain: 'test.test',
  ip: '1.1.1.1',
  userAgent: 'test/1.0',
};

const id1 = getAnonymousUserId('salt', requestDetails);
const id2 = getAnonymousUserIdWithSecret('secret', requestDetails);

Contributing

If you have Docker and Docker Compose installed, you can run docker-compose up to immediately get a working development environment for this package, with Jest running the tests in watch mode.

You can also use yarn link to use your local version of the package in a different project.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.