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

@arraypress/gravatar

v1.0.0

Published

Gravatar avatar URLs and profile API. SHA-256 hashing via Web Crypto API.

Readme

@arraypress/gravatar

Gravatar avatar URLs and profile API. SHA-256 hashing via Web Crypto API. Zero dependencies.

Works in Cloudflare Workers, Node.js 18+, Deno, Bun, and browsers.

Installation

npm install @arraypress/gravatar

Usage

import { getAvatarUrl, getAvatarUrlSync, getProfile } from '@arraypress/gravatar';

// Async — proper SHA-256 hash, matches user's actual Gravatar
const url = await getAvatarUrl('[email protected]');
// → 'https://www.gravatar.com/avatar/abc123...?d=identicon&s=80'

// Sync — simple hash fallback for React render (deterministic identicon)
const url = getAvatarUrlSync('[email protected]');
// → 'https://www.gravatar.com/avatar/1a2b3c...?d=identicon&s=80'

// With pre-computed hash (sync, no await needed)
const url = getAvatarUrl('abc123def456...64chars...', { size: 200 });

// Fetch full profile
const profile = await getProfile('[email protected]');
if (profile) {
  console.log(profile.display_name);
  console.log(profile.avatar_url);
}

API

getAvatarUrl(emailOrHash, options?)

Get a Gravatar avatar URL. Async when given an email (computes SHA-256), sync when given a pre-computed 64-char hex hash.

Options:

  • size — Image size in pixels, 1-2048 (default 80)
  • default — Fallback image: identicon, mp, monsterid, wavatar, retro, robohash, 404, blank (default identicon)
  • rating — Content rating: g, pg, r, x
  • forceDefault — Always show the default image

getAvatarUrlSync(email, options?)

Get a Gravatar avatar URL synchronously. Uses a simple numeric hash instead of SHA-256, so the URL will show a deterministic identicon but won't match the user's actual Gravatar. Use getAvatarUrl for accurate results.

Useful in React render functions where you can't await.

hashEmail(email)

Compute the SHA-256 hash of an email address per Gravatar spec (trimmed, lowercased).

const hash = await hashEmail('[email protected]');
// → '31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66'

getProfileUrl(email)

Get the Gravatar REST API profile URL for an email.

getProfile(email, options?)

Fetch a Gravatar profile from the v3 REST API. Returns null if not found or on error.

Options:

  • token — Gravatar API bearer token for higher rate limits (100/hr unauthenticated, 1000/hr with token)
const profile = await getProfile('[email protected]', { token: 'grav_xxx' });
// { hash, display_name, profile_url, avatar_url, ... }

Sync vs Async

| Function | Hash | Matches actual Gravatar? | Use case | |----------|------|--------------------------|----------| | getAvatarUrl(email) | SHA-256 (async) | Yes | API responses, server-side | | getAvatarUrlSync(email) | Simple hash (sync) | No (shows identicon) | React render, templates | | getAvatarUrl(hash) | Pre-computed (sync) | Yes | When you've cached the hash |

License

MIT