
Security News
Lovable’s OJ Rewrites Vite’s Dev Server in Rust as AI Lowers the Cost of Forking Open Source
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.
@botparty/nextjs
Advanced tools
Next.js SDK for BotParty auth — middleware, server auth(), route handlers, SSR provider
Next.js SDK for BotParty auth — middleware, server auth(), auto route handlers, and SSR provider. Clerk-like DX for BotParty identity and payments.
npx @botparty/nextjs init
This interactive command will:
.envOptions:
npx @botparty/nextjs init --domain example.com # skip domain prompt
npx @botparty/nextjs init --force # re-register and regenerate
npx @botparty/nextjs init --jwks # host /.well-known/jwks.json instead of registering inline key
npm install @botparty/nextjs
All set automatically by npx @botparty/nextjs init:
BOTPARTY_AUTH_URL=https://id.botparty.club # defaults to this if omitted
BOTPARTY_CLIENT_ID=bp_xxx
BOTPARTY_CLIENT_ASSERTION_KEY=<ES256 PEM private key> # signs client assertions + service JWTs
BOTPARTY_DOMAIN=example.com # your verified domain (optional, defaults to VERCEL_PROJECT_PRODUCTION_URL)
The single BOTPARTY_CLIENT_ASSERTION_KEY does double duty:
client_assertion JWTs (RFC 7523 private_key_jwt)X-BotParty-Service JWTsSHA-256("bp-session-key:" + key)// app/api/botparty/[...botparty]/route.ts
export { GET, POST } from '@botparty/nextjs/handlers';
Handles /login, /callback, /me, /sign-out, /wallet, /ledger automatically.
// middleware.ts
import { botpartyMiddleware, createRouteMatcher } from '@botparty/nextjs/server';
const isPublic = createRouteMatcher(['/api/public(.*)', '/pricing', '/']);
export default botpartyMiddleware((auth, req) => {
if (!isPublic(req)) auth.protect();
});
export const config = { matcher: ['/((?!_next|.*\\..*).*)'] };
// app/layout.tsx
import { BotPartyProvider } from '@botparty/nextjs';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<BotPartyProvider>{children}</BotPartyProvider>
</body>
</html>
);
}
The provider is an async Server Component — it reads the session server-side and hydrates the client with zero waterfall.
import { auth } from '@botparty/nextjs/server';
export async function GET() {
const session = await auth();
if (!session.isAuthenticated) {
return new Response('Unauthorized', { status: 401 });
}
session.userId; // string | null
session.email; // string | null
session.name; // string | null
session.picture; // string | null
session.namespaceId; // string | null (bot namespace)
session.type; // 'human' | 'bot' | null
session.hasLinkedUser; // boolean
session.getToken(); // raw token string
// Helpers
session.protect(); // redirects if not authenticated
session.redirectToSignIn(); // explicit redirect
}
Inside botpartyMiddleware, the auth callback receives:
interface MiddlewareAuthObject {
isAuthenticated: boolean;
type: 'human' | 'bot' | null;
userId: string | null;
namespaceId: string | null;
email: string | null;
protect(): MiddlewareAuthObject; // redirects to login if not authed
redirectToSignIn(): never;
}
Use createPaymentGateway() to charge for API access via the x402 protocol. The gateway handles verification, payment creation, and settlement automatically.
Units: All amounts are integers in USDC atomic units (6 decimals). 1 USDC = 1,000,000 units.
import { createPaymentGateway } from '@botparty/nextjs/server';
const gateway = createPaymentGateway({ serviceName: 'My API' });
Domain and private key are read from env vars automatically (BOTPARTY_DOMAIN, BOTPARTY_CLIENT_ASSERTION_KEY). On Vercel, domain falls back to VERCEL_PROJECT_PRODUCTION_URL if BOTPARTY_DOMAIN is not set.
You can override any of these in the config object:
const gateway = createPaymentGateway({
domain: 'custom.example.com',
serviceName: 'My API',
privateKey: process.env.MY_CUSTOM_KEY!,
});
Charge a flat fee per request:
// app/api/bots/pay-per-call/route.ts
export async function POST(req: Request) {
const check = await gateway.requirePayment(req, {
amount: 10_000,
description: 'Pay-per-call API request ($0.01)',
});
if (!check.authorized) return check.response; // 402 with payTo link
const result = { message: 'Paid request successful!' };
await gateway.claim(check, {
amount: 10_000,
description: 'Pay-per-call API request',
});
return Response.json(result);
}
Request a budget upfront, bill actual cost after processing:
// app/api/bots/dynamic-payment/route.ts
export async function POST(req: Request) {
const check = await gateway.requireBudget(req, {
estimated: 5_000_000,
description: 'AI inference — estimated cost ($5.00)',
});
if (!check.authorized) return check.response; // 402
const actualCost = await doExpensiveWork();
await gateway.claim(check, {
amount: actualCost,
description: `AI inference — actual cost ($${(actualCost / 1_000_000).toFixed(6)})`,
});
return Response.json({ message: 'Done!', charged: actualCost });
}
requirePayment() checks for an approved payment via the facilitator402 with PAYMENT-REQUIRED header and a JSON body containing a payTo link to a /humans/{flowId} multi-step approval flowpayTo link, completes login + top-up + approvalrequirePayment() finds the approved payment, returns authorized: trueclaim() settles the payment via the facilitatorAll hooks and components from @botparty/react are re-exported:
import {
useAuth, useUser, useWallet, useLedger,
SignedIn, SignedOut, HasLinkedUser,
UserButton, NamespaceBadge,
WalletBalance, TransactionList, TopUpButton, SpendingControls,
} from '@botparty/nextjs';
import { SignedIn, SignedOut, UserButton, WalletBalance } from '@botparty/nextjs';
export default function Dashboard() {
return (
<div>
<SignedIn>
<UserButton />
<WalletBalance />
</SignedIn>
<SignedOut>
<a href="/api/botparty/auth/login">Sign in</a>
</SignedOut>
</div>
);
}
__botparty_session 15min, __botparty_refresh 30d) encrypted with key derived from BOTPARTY_CLIENT_ASSERTION_KEYid.botparty.club/.well-known/jwks.jsonWhen you run npx @botparty/nextjs init in an empty directory, it scaffolds a complete demo with:
/) -- sign in button, feature cards/dashboard) -- protected route showing all SDK components:
<UserButton>, <NamespaceBadge>, <WalletBalance>, <TransactionList><TopUpButton>, <SpendingControls>botparty curlGET /api/bots/open -- accepts any authenticated botGET /api/bots/user-required -- requires namespace linked to human accountPOST /api/bots/pay-per-call -- $0.10/call with payment authorizationPOST /api/bots/dynamic-payment -- $5 authorization, $0.20/call| Path | Contents |
|---|---|
@botparty/nextjs | BotPartyProvider, all React hooks + components |
@botparty/nextjs/server | auth(), currentUser(), botpartyMiddleware, createRouteMatcher, session utils |
@botparty/nextjs/handlers | GET, POST catch-all route handlers |
FAQs
Next.js SDK for BotParty auth — middleware, server auth(), route handlers, SSR provider
The npm package @botparty/nextjs receives a total of 32 weekly downloads. As such, @botparty/nextjs popularity was classified as not popular.
We found that @botparty/nextjs 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.

Security News
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.