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/next

v1.0.3

Published

Next.js integration for Idempotix idempotency

Readme

@idempotix/next

Next.js integration for HTTP idempotency. Supports App Router and Pages Router.

npm version

Installation

npm install @idempotix/core @idempotix/next

App Router

// app/api/orders/route.ts
import { next } from '@idempotix/next';

export const POST = next()(async (req) => {
  const order = await createOrder(await req.json());
  return Response.json(order, { status: 201 });
});

Pages Router

// pages/api/orders.ts
import { pages } from '@idempotix/next/pages';

export default pages()(async (req, res) => {
  const order = await createOrder(req.body);
  res.status(201).json(order);
});

Configuration

Both next() and pages() accept the same options:

export const POST = next({
  storage: upstash(), // Storage adapter
  ttl: '1h', // Cache duration
  required: true, // Require Idempotency-Key header
  failOpen: true, // Continue if storage fails
  getKey: (req) => req.headers.get('x-request-id'), // Custom key extraction
  getHash: async (req) => hashObject(await req.json()), // Custom hash
  onHit: (key, response) => {}, // Cache hit callback
  onMiss: (key) => {}, // Cache miss callback
  onError: (key, error) => {}, // Error callback
})(handler);

Pre-configured Factory

Share configuration across routes:

// lib/idempotency.ts
import { configure } from '@idempotix/next';
import { upstash } from '@idempotix/upstash';

export const idempotent = configure({
  storage: upstash(),
  ttl: '1h',
});

// app/api/orders/route.ts
import { idempotent } from '@/lib/idempotency';

export const POST = idempotent()(handler);

Pages Router has its own configure:

// lib/idempotency.ts
import { configure } from '@idempotix/next/pages';

export const idempotent = configure({
  storage: upstash(),
  ttl: '1h',
});

// pages/api/orders.ts
import { idempotent } from '@/lib/idempotency';

export default idempotent()(handler);

Headers

| Header | Direction | Description | | -------------------- | --------- | ------------------------------------- | | Idempotency-Key | Request | Client-provided unique key | | Idempotency-Key | Response | Echo of the key used | | Idempotency-Replay | Response | true when returning cached response |

Error Responses

All errors follow RFC 7807 Problem Details:

| Status | Type | Cause | | ------ | -------------- | ----------------------------------- | | 400 | key-required | Missing key when required: true | | 409 | conflict | Request with same key in progress | | 422 | mismatch | Same key reused with different body |

With Upstash (Serverless)

import { upstash } from '@idempotix/upstash';

export const POST = next({ storage: upstash() })(handler);

License

MIT