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

@idempotix/client

v1.0.0

Published

Client-side idempotency helpers for browser and frontend applications

Readme

@idempotix/client

Client-side utilities for idempotency key generation and response handling.

npm version

Installation

npm install @idempotix/client

Quick Start

import { generateKey } from '@idempotix/client';

const response = await fetch('/api/orders', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Idempotency-Key': generateKey(),
  },
  body: JSON.stringify(order),
});

Key Generation

import { generateKey, generatePrefixedKey, createKeyGenerator } from '@idempotix/client';

// UUID v4
const key = generateKey();
// => '550e8400-e29b-41d4-a716-446655440000'

// Prefixed UUID
const key = generatePrefixedKey('ord');
// => 'ord_550e8400-e29b-41d4-a716-446655440000'

// Deterministic key from components
const key = generateKey('user', userId, 'create-order');
// => 'f8e9b4a2' (consistent hash for same inputs)

// Key generator namespace
const key = createKeyGenerator();
key(); // UUID
key('a', 'b', 'c'); // Deterministic hash
key.prefixed('txn'); // Prefixed UUID

Key Store

Track pending requests to prevent duplicate submissions:

import { createStore } from '@idempotix/client';

const store = createStore({
  prefix: 'Idempotix:',
  ttl: '5m',
  storage: localStorage,
});

// Mark request as pending
store.pending('key-123');

// Check if request is pending
if (store.isPending('key-123')) {
  throw new Error('Request already in progress');
}

// Mark as completed
store.complete('key-123');

// Clear a specific key
store.clear('key-123');

// Clear all Idempotix keys
store.clearAll();

Response Helpers

import { isReplay, isConflict, isMismatch, getRetryAfter } from '@idempotix/client';

const response = await fetch('/api/orders', { ... });

// Check if response was served from cache
if (isReplay(response)) {
  console.log('Cached response');
}

// Handle 409 Conflict
if (isConflict(response)) {
  const seconds = getRetryAfter(response);
  await delay(seconds * 1000);
  // Retry with same key...
}

// Handle 422 Mismatch
if (isMismatch(response)) {
  // Key was reused with different body - generate new key
}

Usage with Fetch Libraries

ky

import ky from 'ky';
import { generateKey, IDEMPOTENCY_KEY_HEADER } from '@idempotix/client';

const api = ky.extend({
  hooks: {
    beforeRequest: [
      (request) => {
        if (['POST', 'PUT', 'PATCH'].includes(request.method)) {
          request.headers.set(IDEMPOTENCY_KEY_HEADER, generateKey());
        }
      },
    ],
  },
});

axios

import axios from 'axios';
import { generateKey, IDEMPOTENCY_KEY_HEADER } from '@idempotix/client';

const api = axios.create();

api.interceptors.request.use((config) => {
  if (['post', 'put', 'patch'].includes(config.method ?? '')) {
    config.headers[IDEMPOTENCY_KEY_HEADER] = generateKey();
  }
  return config;
});

Constants

import { IDEMPOTENCY_KEY_HEADER, IDEMPOTENCY_REPLAY_HEADER } from '@idempotix/client';

IDEMPOTENCY_KEY_HEADER; // 'Idempotency-Key'
IDEMPOTENCY_REPLAY_HEADER; // 'Idempotency-Replay'

License

MIT