
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
@idempotix/next
Advanced tools
Next.js integration for HTTP idempotency. Supports App Router and Pages Router.
npm install @idempotix/core @idempotix/next
// 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/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);
});
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);
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);
| 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 |
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 |
import { upstash } from '@idempotix/upstash';
export const POST = next({ storage: upstash() })(handler);
MIT
FAQs
Next.js integration for Idempotix idempotency
We found that @idempotix/next demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.