@21st-sdk/react 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 AN Dev (an.dev)
3
+ Copyright (c) 2026 21st.dev
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # @an-sdk/react
1
+ # @21st-sdk/react
2
2
 
3
- React components for building AI agent chat UIs powered by [AN](https://an.dev). Drop-in chat interface with tool renderers, theming, and full customization.
3
+ React components for building AI agent chat UIs powered by [21st Agents](https://21st.dev/agents). Drop-in chat interface with tool renderers, theming, and full customization.
4
4
 
5
5
  Built on [Vercel AI SDK v5](https://sdk.vercel.ai) — no custom hooks or state management. Just components.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install @an-sdk/react ai @ai-sdk/react
10
+ npm install @21st-sdk/react ai @ai-sdk/react
11
11
  ```
12
12
 
13
13
  ## Quick Start
@@ -16,14 +16,14 @@ npm install @an-sdk/react ai @ai-sdk/react
16
16
  "use client";
17
17
 
18
18
  import { useChat } from "@ai-sdk/react";
19
- import { AnAgentChat, createAnChat } from "@an-sdk/react";
20
- import "@an-sdk/react/styles.css";
19
+ import { AgentChat, createAgentChat } from "@21st-sdk/react";
20
+ import "@21st-sdk/react/styles.css";
21
21
  import { useMemo } from "react";
22
22
 
23
23
  export default function Chat() {
24
24
  const chat = useMemo(
25
25
  () =>
26
- createAnChat({
26
+ createAgentChat({
27
27
  agent: "your-agent-slug",
28
28
  getToken: async () => "your_an_sk_token",
29
29
  }),
@@ -33,7 +33,7 @@ export default function Chat() {
33
33
  const { messages, sendMessage, status, stop, error } = useChat({ chat });
34
34
 
35
35
  return (
36
- <AnAgentChat
36
+ <AgentChat
37
37
  messages={messages}
38
38
  onSend={(msg) =>
39
39
  sendMessage({
@@ -48,7 +48,7 @@ export default function Chat() {
48
48
  }
49
49
  ```
50
50
 
51
- That's it. You get a full chat UI with message rendering, tool visualization, auto-scroll, and streaming — all wired to your AN agent.
51
+ That's it. You get a full chat UI with message rendering, tool visualization, auto-scroll, and streaming — all wired to your deployed agent.
52
52
 
53
53
  ## Customization
54
54
 
@@ -56,10 +56,10 @@ Four levels of customization, from simple to full control:
56
56
 
57
57
  ### 1. Theme tokens
58
58
 
59
- Apply a theme JSON from the [AN Playground](https://an.dev/an/playground):
59
+ Apply a theme JSON from the [Playground](https://21st.dev/agents/playground):
60
60
 
61
61
  ```tsx
62
- <AnAgentChat theme={playgroundTheme} colorMode="dark" />
62
+ <AgentChat theme={playgroundTheme} colorMode="dark" />
63
63
  ```
64
64
 
65
65
  ### 2. Class overrides
@@ -67,7 +67,7 @@ Apply a theme JSON from the [AN Playground](https://an.dev/an/playground):
67
67
  Override styles per element:
68
68
 
69
69
  ```tsx
70
- <AnAgentChat
70
+ <AgentChat
71
71
  classNames={{
72
72
  root: "rounded-2xl border",
73
73
  messageList: "px-8",
@@ -82,7 +82,7 @@ Override styles per element:
82
82
  Swap sub-components entirely:
83
83
 
84
84
  ```tsx
85
- <AnAgentChat
85
+ <AgentChat
86
86
  slots={{
87
87
  InputBar: MyCustomInput,
88
88
  UserMessage: MyUserBubble,
@@ -96,7 +96,7 @@ Swap sub-components entirely:
96
96
  Build from scratch with individual imports:
97
97
 
98
98
  ```tsx
99
- import { MessageList, InputBar, ToolRenderer } from "@an-sdk/react";
99
+ import { MessageList, InputBar, ToolRenderer } from "@21st-sdk/react";
100
100
  ```
101
101
 
102
102
  ## CSS
@@ -104,7 +104,7 @@ import { MessageList, InputBar, ToolRenderer } from "@an-sdk/react";
104
104
  Import the stylesheet once in your app:
105
105
 
106
106
  ```tsx
107
- import "@an-sdk/react/styles.css";
107
+ import "@21st-sdk/react/styles.css";
108
108
  ```
109
109
 
110
110
  No Tailwind peer dependency required — CSS is pre-compiled. All elements have stable `an-*` class names for custom styling:
@@ -123,12 +123,12 @@ No Tailwind peer dependency required — CSS is pre-compiled. All elements have
123
123
 
124
124
  ## API Reference
125
125
 
126
- ### `createAnChat(options)`
126
+ ### `createAgentChat(options)`
127
127
 
128
- Creates an AI SDK `Chat` instance pointed at the AN Relay API.
128
+ Creates an AI SDK `Chat` instance pointed at the relay API.
129
129
 
130
130
  ```ts
131
- createAnChat({
131
+ createAgentChat({
132
132
  agent: string; // Agent slug from your dashboard
133
133
  getToken: () => Promise<string>; // Returns your an_sk_ API key
134
134
  apiUrl?: string; // Default: "https://relay.an.dev"
@@ -140,7 +140,7 @@ createAnChat({
140
140
 
141
141
  Returns a standard `Chat<UIMessage>` — pass it to `useChat({ chat })`.
142
142
 
143
- ### `<AnAgentChat />`
143
+ ### `<AgentChat />`
144
144
 
145
145
  Drop-in chat component.
146
146
 
@@ -151,10 +151,10 @@ Drop-in chat component.
151
151
  | `status` | `ChatStatus` | `"ready" \| "submitted" \| "streaming" \| "error"` |
152
152
  | `onStop` | `() => void` | Stop generation |
153
153
  | `error` | `Error` | Error to display |
154
- | `theme` | `AnTheme` | Theme from playground |
154
+ | `theme` | `ChatTheme` | Theme from playground |
155
155
  | `colorMode` | `"light" \| "dark" \| "auto"` | Color mode |
156
- | `classNames` | `Partial<AnClassNames>` | Per-element CSS overrides |
157
- | `slots` | `Partial<AnSlots>` | Component swapping |
156
+ | `classNames` | `Partial<ChatClassNames>` | Per-element CSS overrides |
157
+ | `slots` | `Partial<ChatSlots>` | Component swapping |
158
158
  | `className` | `string` | Root element class |
159
159
  | `style` | `CSSProperties` | Root element style |
160
160
  | `modelSelector` | `{ models, activeModelId?, onModelChange? }` | Model picker (for custom backends) |
@@ -194,7 +194,7 @@ Manually inject CSS variables from a playground theme JSON.
194
194
  ## Theme Type
195
195
 
196
196
  ```ts
197
- interface AnTheme {
197
+ interface ChatTheme {
198
198
  theme: Record<string, string>; // Shared: font, spacing, accent
199
199
  light: Record<string, string>; // Light mode CSS vars
200
200
  dark: Record<string, string>; // Dark mode CSS vars
@@ -206,11 +206,11 @@ interface AnTheme {
206
206
  The SDK exports pre-defined model constants for convenience:
207
207
 
208
208
  ```ts
209
- import { AN_CLAUDE_MODELS, AN_DEFAULT_MODEL_ID } from "@an-sdk/react"
210
- import type { AnModelOption, AnClaudeModelId } from "@an-sdk/react"
209
+ import { CLAUDE_MODELS, DEFAULT_MODEL_ID } from "@21st-sdk/react"
210
+ import type { ModelOption, ClaudeModelId } from "@21st-sdk/react"
211
211
  ```
212
212
 
213
- > **Note:** When using `createAnChat()` with the AN Relay, the model is set server-side in the agent config. The `modelSelector` prop is for building UIs with custom backends.
213
+ > **Note:** When using `createAgentChat()` with the relay, the model is set server-side in the agent config. The `modelSelector` prop is for building UIs with custom backends.
214
214
 
215
215
  ## License
216
216
 
package/dist/index.cjs CHANGED
@@ -11730,13 +11730,16 @@ __export(index_exports, {
11730
11730
  AN_CLAUDE_MODELS: () => AN_CLAUDE_MODELS,
11731
11731
  AN_DEFAULT_MODEL_ID: () => AN_DEFAULT_MODEL_ID,
11732
11732
  ActionRow: () => ActionRow,
11733
+ AgentChat: () => AgentChat,
11733
11734
  AnAgentChat: () => AnAgentChat,
11734
11735
  AttachmentButton: () => AttachmentButton,
11735
11736
  BashTool: () => BashTool,
11737
+ CLAUDE_MODELS: () => CLAUDE_MODELS,
11736
11738
  CheckIcon16: () => CheckIcon16,
11737
11739
  ChevronDown: () => ChevronDown,
11738
11740
  ChevronRightIcon: () => ChevronRightIcon,
11739
11741
  ContextItems: () => ContextItems,
11742
+ DEFAULT_MODEL_ID: () => DEFAULT_MODEL_ID,
11740
11743
  DEFAULT_THEME_CONFIG: () => DEFAULT_THEME_CONFIG,
11741
11744
  DateDivider: () => DateDivider,
11742
11745
  EditTool: () => EditTool,
@@ -11780,6 +11783,7 @@ __export(index_exports, {
11780
11783
  WindowChrome: () => WindowChrome,
11781
11784
  WriteTool: () => EditTool,
11782
11785
  applyTheme: () => applyTheme,
11786
+ createAgentChat: () => createAgentChat,
11783
11787
  createAnChat: () => createAnChat,
11784
11788
  extractThemeConfig: () => extractThemeConfig,
11785
11789
  loadGoogleFont: () => loadGoogleFont,
@@ -13762,7 +13766,7 @@ function applyTheme(element, theme, colorMode = "auto") {
13762
13766
  init_cn();
13763
13767
  init_theme_config();
13764
13768
  var import_jsx_runtime34 = require("react/jsx-runtime");
13765
- function AnAgentChat({
13769
+ function AgentChat({
13766
13770
  messages,
13767
13771
  onSend,
13768
13772
  status,
@@ -13846,6 +13850,7 @@ function AnAgentChat({
13846
13850
  }
13847
13851
  ) });
13848
13852
  }
13853
+ var AnAgentChat = AgentChat;
13849
13854
 
13850
13855
  // src/create-an-chat.ts
13851
13856
  var import_react51 = require("@ai-sdk/react");
@@ -13873,7 +13878,7 @@ function createTokenFetcher(tokenUrl, agent) {
13873
13878
  return data.token;
13874
13879
  };
13875
13880
  }
13876
- function createAnChat(options) {
13881
+ function createAgentChat(options) {
13877
13882
  const {
13878
13883
  agent,
13879
13884
  tokenUrl,
@@ -13886,7 +13891,7 @@ function createAnChat(options) {
13886
13891
  } = options;
13887
13892
  const getToken = getTokenFn || (tokenUrl ? createTokenFetcher(tokenUrl, agent) : null);
13888
13893
  if (!getToken) {
13889
- throw new Error("createAnChat: provide either tokenUrl or getToken");
13894
+ throw new Error("createAgentChat: provide either tokenUrl or getToken");
13890
13895
  }
13891
13896
  return new import_react51.Chat({
13892
13897
  id: sandboxId || `sandbox-${agent}`,
@@ -13905,6 +13910,7 @@ function createAnChat(options) {
13905
13910
  onError
13906
13911
  });
13907
13912
  }
13913
+ var createAnChat = createAgentChat;
13908
13914
 
13909
13915
  // src/index.ts
13910
13916
  init_theme_config();
@@ -15294,24 +15300,29 @@ init_tool_icons();
15294
15300
  init_file_ext_icon();
15295
15301
 
15296
15302
  // src/models.ts
15297
- var AN_CLAUDE_MODELS = [
15303
+ var CLAUDE_MODELS = [
15298
15304
  { id: "sonnet", name: "Sonnet", version: "4.6" },
15299
15305
  { id: "opus", name: "Opus", version: "4.6" },
15300
15306
  { id: "haiku", name: "Haiku", version: "4.5" }
15301
15307
  ];
15302
- var AN_DEFAULT_MODEL_ID = "sonnet";
15308
+ var DEFAULT_MODEL_ID = "sonnet";
15309
+ var AN_CLAUDE_MODELS = CLAUDE_MODELS;
15310
+ var AN_DEFAULT_MODEL_ID = DEFAULT_MODEL_ID;
15303
15311
  // Annotate the CommonJS export names for ESM import in node:
15304
15312
  0 && (module.exports = {
15305
15313
  AN_CLAUDE_MODELS,
15306
15314
  AN_DEFAULT_MODEL_ID,
15307
15315
  ActionRow,
15316
+ AgentChat,
15308
15317
  AnAgentChat,
15309
15318
  AttachmentButton,
15310
15319
  BashTool,
15320
+ CLAUDE_MODELS,
15311
15321
  CheckIcon16,
15312
15322
  ChevronDown,
15313
15323
  ChevronRightIcon,
15314
15324
  ContextItems,
15325
+ DEFAULT_MODEL_ID,
15315
15326
  DEFAULT_THEME_CONFIG,
15316
15327
  DateDivider,
15317
15328
  EditTool,
@@ -15355,6 +15366,7 @@ var AN_DEFAULT_MODEL_ID = "sonnet";
15355
15366
  WindowChrome,
15356
15367
  WriteTool,
15357
15368
  applyTheme,
15369
+ createAgentChat,
15358
15370
  createAnChat,
15359
15371
  extractThemeConfig,
15360
15372
  loadGoogleFont,