
Company News
AWS Security Hub Adds Socket for Supply Chain Security
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.
@payweave/next
Advanced tools
Next.js integration for PayWeave - accept per-request USD micropayments on Next.js API routes.
Next.js integration for PayWeave - accept per-request USD micropayments on Next.js API routes.
npm install @payweave/next
// app/api/weather/route.ts
import { Payweave } from '@payweave/next';
import { NextRequest, NextResponse } from 'next/server';
const payweave = new Payweave(
process.env.PAYWEAVE_APP_ID!,
process.env.PAYWEAVE_APP_SECRET!
);
export const GET = payweave.charge(
{ price: '0.001', description: 'Weather API' },
async (req: NextRequest) => {
return NextResponse.json({ temp: 72, unit: 'F' });
}
);
new Payweave(appId, appSecret, baseUrl?)| Parameter | Type | Description |
|---|---|---|
appId | string | Your app key ID |
appSecret | string | Your app secret |
baseUrl | string? | API base URL (defaults to https://api.payweave.app) |
payweave.charge(options, handler)Wraps a route handler with payment verification. Returns (req: NextRequest) => Promise<NextResponse>.
| Option | Type | Description |
|---|---|---|
price | string | (req: NextRequest) => string | Promise<string> | USD price per request |
description | string? | Human-readable description |
meta | Record<string, string>? | API metadata for agent discovery |
Note: Unlike other adapters, the Next.js adapter wraps your handler function directly. The handler is passed as the second argument to
charge().
// app/api/search/route.ts
import { Payweave } from '@payweave/next';
import { NextRequest, NextResponse } from 'next/server';
const payweave = new Payweave(
process.env.PAYWEAVE_APP_ID!,
process.env.PAYWEAVE_APP_SECRET!
);
export const GET = payweave.charge(
{ price: '0.01' },
async (req: NextRequest) => {
const query = req.nextUrl.searchParams.get('q');
return NextResponse.json({ results: [], query });
}
);
export const POST = payweave.charge(
{ price: '0.02', description: 'Advanced search' },
async (req: NextRequest) => {
const body = await req.json();
return NextResponse.json({ results: [], query: body.query });
}
);
export const POST = payweave.charge(
{
price: async (req: NextRequest) => {
const body = await req.clone().json();
return body.premium ? '0.05' : '0.01';
},
description: 'Text generation',
},
async (req: NextRequest) => {
const body = await req.json();
return NextResponse.json({ text: 'generated' });
}
);
export const POST = payweave.charge(
{
price: '0.005',
description: 'Sentiment analysis',
meta: {
'method': 'POST',
'input.content-type': 'application/json',
'input.schema': '{"type":"object","properties":{"text":{"type":"string"}}}',
'output.schema': '{"type":"object","properties":{"score":{"type":"number"}}}',
},
},
async (req: NextRequest) => {
const { text } = await req.json();
return NextResponse.json({ score: 0.85, text });
}
);
app/api/
weather/route.ts -> export const GET = payweave.charge(...)
forecast/route.ts -> export const GET = payweave.charge(...)
analyze/route.ts -> export const POST = payweave.charge(...)
402 Payment Required and pricing infoAuthorization: Payment <credential>Payment-Receipt header to the responseMIT
FAQs
Next.js integration for PayWeave - accept per-request USD micropayments on Next.js API routes.
The npm package @payweave/next receives a total of 6 weekly downloads. As such, @payweave/next popularity was classified as not popular.
We found that @payweave/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.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.

Research
/Security News
Popular npm packages keyv and cacheable compromised.

Security News
A misconfiguration gave three Anthropic models internet access, and one, believing it was in a simulation, shipped a credential-stealing package to PyPI.