@21st-sdk/nextjs has 1,360 recorded weekly downloads on npm, an increase of 222% over the past 30 days, ranking #1989 of 3,247 tracked listings.
About @21st-sdk/nextjs
@21st-sdk/nextjs
Next.js integration for 21st Agents AI agent chat. Provides a server-side token handler so your API key never reaches the client.
Install
npm install @21st-sdk/nextjs @21st-sdk/react ai @ai-sdk/react
Quick Start
1. Set your API key
# .env.local
API_KEY_21ST=an_sk_your_key_here
Get your API key from the API keys page.
2. Create the token route (one line)
// app/api/agent/token/route.ts
import { createTokenHandler } from "@21st-sdk/nextjs/server"
export const POST = createTokenHandler({
apiKey: process.env.API_KEY_21ST!,
})
3. Use in your page
// app/page.tsx
"use client"
import { useChat } from "@ai-sdk/react"
import { AgentChat, createAgentChat } from "@21st-sdk/nextjs"
import "@21st-sdk/react/styles.css"
import { useMemo } from "react"
export default function Chat() {
const chat = useMemo(
() => createAgentChat({
agent: "your-agent-slug",
tokenUrl: "/api/agent/token",
}),
[],
)
const { messages, sendMessage, status, stop, error } = useChat({ chat })
return (
<AgentChat
messages={messages}
onSend={(msg) =>
sendMessage({ parts: [{ type: "text", text: msg.content }] })
}
status={status}
onStop={stop}
error={error}
/>
)
}
That's it. Your an_sk_ API key stays on the server. The client only receives short-lived JWTs.
How It Works
Browser Your Next.js Server Relay
| | |
|-- POST /api/agent/token ------>| |
| |-- POST /v1/tokens -------->|
| | (with an_sk_ key) |
| |<-- { token, expiresAt } ---|
|<-- { token, expiresAt } ------| |
| |
|-- POST /v1/chat/:agent ------(with short-lived JWT)------->|
|<-- streaming response -----(SSE)---------------------------|
License
MIT
Description from the npm listing.
- nextjs
- react
- ai
- agent
- chat
- ai-sdk
- 21st
- 21st.dev
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm AI SDKs plugins
All 20 @21st-sdk/nextjs alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@21st-sdk/nextjs. First seen Oct 16, 2026; last successful collection Oct 31, 2026. See the methodology.