Choosing a React AI chat component for a site with real traffic
Choosing a React AI chat component for a site with 200,000 monthly visits comes down to two numbers: what each answer costs you and where the checks against prompt injection run.
Published on
Choosing a React AI chat component for a site with 200,000 monthly visits comes down to two numbers: what each answer costs you and where the checks against prompt injection run. The four options compared here, as of 23 November 2026, are assistant-ui, AI Elements, LlamaIndex chat-ui and the AI Connect React package. Three of them render a chat that calls your own backend route with your own model key, so your bill grows with each message. The fourth runs each answer on the visitor's own AI account. This comparison covers licence, payer, guard location, package weight, server rendering, theming and the install, with the date behind each figure.
Key points:
- Vercel's AI SDK Elements will be deprecated at the end of November 2026; new projects move to AI Elements in shadcn/ui, which ships 21 copy-paste patterns and no npm package.
- LlamaIndex archived its chat-ui repository on 3 November 2026; the last npm release is 0.6.1.
- On GPT-6.2 Sol at $2.00 per million input tokens and $10.00 per million output tokens (November 2026), an answer of 2,000 input and 300 output tokens costs your site $0.007.
- @tensorpass/aiconnect-react 0.1.2 reached npm on 16 November 2026 under Apache 2.0, with SLSA provenance signed by GitHub Actions.
What production changes for a React AI chat component
A demo chat serves one developer. A public page serves thousands of anonymous visitors, and three things change at that scale.
The first is cost. Each message that hits a route holding your API key (the secret that bills a model provider account) adds tokens to your invoice. The assistant-ui manual setup puts OPENAI_API_KEY in a .env file and streams from an /api/chat route. LlamaIndex chat-ui connects its ChatSection to the Vercel AI SDK useChat hook, which calls the same kind of route. The Vercel AI Elements README recommends an AI_GATEWAY_API_KEY in .env.local.
The second is abuse. The OWASP Top 10 for LLM Applications 2025 defines prompt injection in one line: "A Prompt Injection Vulnerability occurs when user prompts alter the LLM's behavior or output in unintended ways." On a public page, any visitor can type those prompts, and any review or comment your tools return can carry them.
The third is the page itself. A marketing page has to render for search engines, match the brand palette in light and dark themes, and keep its first load small. A chat panel that breaks any of these costs traffic.
Four React options on one table
The SERP for this query is led by roundups. Create UI's list of 8 libraries, dated 20 October 2026, places its own paid kit first, at a lifetime price of $99 to $249 during a 50% promotion shown on 23 November 2026. None of the roundups states who pays per message or where the guards sit. The table below does.
| Component | Licence | Backend required | Who pays per message | Guard location |
|---|---|---|---|---|
assistant-ui (@assistant-ui/react 0.15.38) | MIT | Yes, a runtime to your server or AI SDK route | Your site, through its provider key | Your server route |
| AI Elements (Vercel, moving to shadcn/ui) | Code copied into your repo | Yes, a Next.js app with the AI SDK | Your site, through its key or AI Gateway | Your server route |
LlamaIndex chat-ui (@llamaindex/chat-ui 0.6.1) | MIT, archived 3 Nov 2026 | Yes, a route behind useChat | Your site, through its provider key | Your server route |
AI Connect React (@tensorpass/aiconnect-react 0.1.5) | Apache 2.0 | An MCP server for your tools only | The visitor, on their own AI account | Visitor's browser, plus checks on your MCP server |
assistant-ui has 13.4k stars on GitHub and the widest set of runtimes: AI SDK, LangGraph, LangChain, AG-UI, A2A and a custom data stream. AI Elements is a set of shadcn/ui compositions with 21 patterns, from Chat and Message to Reasoning and Tool. LlamaIndex chat-ui has 596 stars and ships code and LaTeX rendering with highlight.js and KaTeX; since 3 November 2026 the repository is a read-only archive that takes no new commits. AI Connect is our SDK: four packages on npm since 16 November 2026, with React 19 as its minimum version.
Who pays per message in each option
With assistant-ui, AI Elements and LlamaIndex chat-ui, your site pays for every token. The cost scales with visitors who open the chat, so it is worth sizing before launch.
Here is a worked example for the persona of this page, using assumptions you should replace with your own analytics:
- Traffic. 200,000 visits a month.
- Chat opens. 2% of visits start a conversation, which gives 4,000 conversations.
- Depth. 5 answers per conversation, which gives 20,000 answers.
- Tokens. 2,000 input tokens (system prompt, history, retrieved context) and 300 output tokens per answer.
- Price. GPT-6.2 Sol, standard tier, November 2026: $2.00 per million input tokens and $10.00 per million output tokens.
- Per answer. 2,000 × $2.00 / 1,000,000 = $0.004 for input, plus 300 × $10.00 / 1,000,000 = $0.003 for output, so $0.007.
- Per month. 20,000 × $0.007 = $140, before retries, tool calls or bot traffic.
Double the chat rate to 4% and the bill reaches $280 a month. Move to GPT-6.2 Astra at $8.00 input and $40.00 output per million tokens and the same 20,000 answers cost $560.
With AI Connect, the inference runs on the account the visitor already holds through the AI Wallet browser extension: a ChatGPT, Claude or Gemini plan, an OpenRouter account or an API key. Your site pays nothing for the inference. A visitor without the wallet signs in with OpenRouter or takes the TensorPass plan. Your site still hosts its MCP server, so its total cost stays above zero.
Where the guards against prompt injection run
In the three server-route options, the guards are code you write in your route. The assistant-ui manual installation names the risk directly: the system prompt and tool schemas arrive from the client, and the docs say "Treat both as untrusted input." The component libraries render messages; filtering questions, stripping planted instructions from tool results and blocking exfiltration links stay on your side.
In AI Connect, useAiChat({ system, tools, guards }) runs guards in the visitor's browser on every conversation with no setup. The question guard stops a question longer than 2,000 characters by default, a long base64 blob, or a match of 18 injection patterns in English, French and Hebrew, such as "ignore instructions", a role change or a spoofed envelope tag. A random salt drawn per conversation wraps your instructions and each tool result in salted envelopes, so a review that writes a closing tag stays inside the tool result as data. The answer guard checks each streamed piece and stops on an image, a link outside your origin or your allowedLinkHosts, an unlisted email address, or a match of your denyPatterns. A stopped turn carries blocked: 'question' or blocked: 'answer' and shows your safe answer.
These guards reduce a risk without removing it. OWASP states that it is "unclear if there are fool-proof methods of prevention." The browser receives the whole answer, so data that must stay private is held back on your MCP server. Run checkToolResult(text, guards) on each tool result before it returns, and build results from public fields by name. Our AI chatbot security guide for a public website covers the threat model in full.
Bundle weight, server rendering and SEO
Unpacked npm size is the closest public figure for weight. It overstates what ships to the browser after tree shaking, so treat it as an upper bound and measure your own build.
| Package | Version | Unpacked size |
|---|---|---|
@assistant-ui/react | 0.15.38 | 3,058,054 bytes |
@llamaindex/chat-ui | 0.6.1 | 1,835,897 bytes |
@tensorpass/aiconnect-react | 0.1.5 | 393,080 bytes, plus its core package |
| AI Elements | copied source | only the patterns you add |
For SEO, Google Search Central writes that "server-side or pre-rendering is still a great idea because it makes your website faster for users and crawlers," and adds that "not all bots can run JavaScript." Keep the page copy in the server HTML and load the chat as a client island.
AI Connect follows that pattern. The server cannot see the visitor's wallet, so AiConnectProvider renders the checking state through useSyncExternalStore during the server render and the hydration, then switches to the browser's state. The Next.js quickstart loads the chat panel with a dynamic import and ssr: false, which keeps the panel, the chat and the MCP client out of the first page load. Render your AI button in every state so the layout holds still when the state arrives.
Theming with design tokens and a dark mode
AI Elements and LlamaIndex chat-ui read the shadcn/ui CSS variables through Tailwind CSS, so they inherit your existing theme. AI Elements supports only the CSS variables mode of shadcn/ui.
AI Connect reads design tokens (named CSS custom properties that hold a colour, font or size) prefixed --aic-* from @tensorpass/aiconnect-design, bundled in styles.css. The set covers type (--aic-font, --aic-ink), surfaces (--aic-surface, --aic-border), the main button (--aic-accent, --aic-accent-ink) and the card (--aic-radius, --aic-width). The light value of --aic-focus reaches a 3:1 contrast against light surfaces, as WCAG 1.4.11 asks. Map your own tokens onto these in a stylesheet loaded after styles.css.
Dark mode is an attribute. data-aic-theme="dark" turns on the dark palette below that element, and data-aic-theme="auto" follows the system setting. Put it on an element that wraps the provider, such as <html lang="en" data-aic-theme="auto">. If you override a token on :root, set its dark value as well, since your rule has the same specificity and wins. The theming guide lists every token.
Install AI Connect as your React AI chat component
The React package needs React 19 or later. Version 0.1.2 was published on 16 November 2026 at 20:13 UTC with an SLSA provenance attestation, and 0.1.5 has been the latest release on npm since 19 November 2026 at 23:33 UTC. Each release since 0.1.1 is tied by npm provenance (a signed record linking a package to the commit and workflow that built it) to the public GitHub repository.
- Install. Run
npm install @tensorpass/aiconnect @tensorpass/aiconnect-react; the design package comes with it. - Check provenance. The npm registry lists an SLSA attestation for each version from 0.1.1, published by GitHub Actions as a trusted publisher.
- Add the site key. Put
VITE_TENSORPASS_SITE_KEY=tpk_...in.env.local; the key is public and works onlocalhostat once. - Create the client once. Build one
AiConnectper page and keep it stable across renders. - Load the styles. Import
@tensorpass/aiconnect-react/styles.cssonce. - Wrap the app. Place
<AiConnectProvider client={client}>around the chat. - Start the chat. Call
useAiChat({ system, tools, guards })with tools read from your MCP server, and disable the send button whilebusyis true, sincesendcalls are not queued.
The React quickstart in our docs carries the full sample. To expose your catalogue or docs as tools, follow our guide to give your site's AI chat real tools with its own MCP server.
Migrating from AI SDK Elements before the deprecation
The vercel/ai-elements README states: "This project will be deprecated at the end of November 2026 and replaced by AI Elements from shadcn/ui." New projects start from the shadcn/ui version with pnpm dlx shadcn@latest add trace code-block, then copy each pattern page.
Existing projects have a lighter path. The shadcn/ui page states that the copied code "is yours, and it keeps working as is," so the deprecation leaves your copied components in place. Plan the move when you next touch the chat, and use it to decide the backend question: keep the AI SDK route and your key, or pass aiconnect.fetch to the Vercel AI SDK so its requests run on the visitor's account.
FAQ: picking a chat component for React
Is a React AI chat component free to run?
The four libraries compared here are free to install: assistant-ui and LlamaIndex chat-ui under MIT, AI Elements as copied source, AI Connect under Apache 2.0. Running them differs. Three call a model with your key, and at $0.007 per answer on GPT-6.2 Sol in November 2026, 20,000 answers cost $140 a month. With AI Connect the visitor's account answers and your site pays no inference.
Does assistant-ui keep my API key off the client?
Yes, when you follow its setup. The manual installation stores OPENAI_API_KEY in a .env file read by a server route, and the client only calls /api/chat. The route then pays for every answer and has to treat the client-supplied system prompt and tool schemas as untrusted input. Rate limits and abuse filtering on that route are your code, since assistant-ui renders the chat and the runtime.
Can I still start a project on Vercel AI SDK Elements?
You can, though the repository will be deprecated at the end of November 2026. Vercel and shadcn/ui direct new projects to AI Elements in shadcn/ui, which offers 21 patterns installed through the shadcn CLI. Code already copied from elements.ai-sdk.dev stays in your repository and keeps working, so an existing chat needs no emergency migration.
Does a chat panel hurt the SEO of a public page?
It hurts only when it blocks the page content. Google advises server-side or pre-rendering, and not all bots run JavaScript. Keep the article or product copy in the server HTML and load the chat on the client. AI Connect renders a stable checking state on the server, and its Next.js quickstart lazy-loads the panel with ssr: false.
How TensorPass helps your React chat ship
We built AI Connect for developers who want a public chat without an inference bill that grows with each visitor.
Free packages. The AI Connect SDK, AI Wallet and the site key are free. The SDK has been public on GitHub under Apache 2.0 since 12 November 2026, and its four packages have been on npm since 16 November 2026 with provenance signed by the GitHub build.
Visitors without an AI account. The TensorPass plan costs the visitor US$5 a month (Light), US$20 (Pro) or US$50 (Max). A site earns 5% of each plan payment made from its AI window for 12 months, with a 60-day hold, paid in USDC once US$50 is available.
Done for you. We make a site AI native in under 24 hours, priced on quote. AI Wallet and the connect window run in English, French, Hebrew, Arabic and simplified Chinese.
Start with the React quickstart and a chat running on localhost in one session.
Your shortlist checks before launch
Run four checks on each candidate with your own numbers. Price 20,000 answers at your model's rate. List the guards you would write and where they run. Build the page and measure the shipped JavaScript. Toggle dark mode with your tokens. The full guide to every way to add AI chat to a site and our AI chatbot pricing comparison by who pays for each answer give the wider context. If the per-message bill is the deciding factor, the AI Connect package is the React AI chat component that moves it to the visitor's own account.
Also worth reading:
- Add an AI chatbot to your website with no API key on your server
- Give your site's AI chat real tools with its own MCP server
- AI chatbot security for a public website
- AI chatbot pricing compared by who pays for each answer
- Build a RAG chatbot over your own website content
Sources:
- The Best AI Chat UI Components for React in 2026: Create UI, 20 October 2026
- assistant-ui: Typescript/React Library for AI Chat: assistant-ui on GitHub, read 23 November 2026
- Manual installation: assistant-ui documentation, read 23 November 2026
- @assistant-ui/react registry entry, version 0.15.38: npm, read 23 November 2026
- Chat UI components for LLM apps: LlamaIndex on GitHub, archived 3 November 2026
- @llamaindex/chat-ui registry entry, version 0.6.1: npm, read 23 November 2026
- vercel/ai-elements: Vercel on GitHub, read 23 November 2026
- AI Elements: shadcn/ui documentation, read 23 November 2026
- React reference: TensorPass docs, read 23 November 2026
- React quickstart: TensorPass docs, read 23 November 2026
- Next.js quickstart: TensorPass docs, read 23 November 2026
- Guards: TensorPass docs, read 23 November 2026
- Theming: TensorPass docs, read 23 November 2026
- Changelog: TensorPass docs, 20 November 2026
- @tensorpass/aiconnect-react registry entry: npm, 19 November 2026
- LLM01:2025 Prompt Injection: OWASP Gen AI Security Project, 2025 edition
- Understand the JavaScript SEO basics: Google Search Central, read 23 November 2026
- API pricing: OpenAI, read 23 November 2026
Questions
- Is a React AI chat component free to run?
- The four libraries compared here are free to install: assistant-ui and LlamaIndex chat-ui under MIT, AI Elements as copied source, AI Connect under Apache 2.0. Running them differs. Three call a model with your key, and at $0.007 per answer on GPT-6.2 Sol in November 2026, 20,000 answers cost $140 a month. With AI Connect the visitor's account answers and your site pays no inference.
- Does assistant-ui keep my API key off the client?
- Yes, when you follow its setup. The manual installation stores OPENAI_API_KEY in a .env file read by a server route, and the client only calls /api/chat. The route then pays for every answer and has to treat the client-supplied system prompt and tool schemas as untrusted input. Rate limits and abuse filtering on that route are your code, since assistant-ui renders the chat and the runtime.
- Can I still start a project on Vercel AI SDK Elements?
- You can, though the repository will be deprecated at the end of November 2026. Vercel and shadcn/ui direct new projects to AI Elements in shadcn/ui, which offers 21 patterns installed through the shadcn CLI. Code already copied from elements.ai-sdk.dev stays in your repository and keeps working, so an existing chat needs no emergency migration.
- Does a chat panel hurt the SEO of a public page?
- It hurts only when it blocks the page content. Google advises server-side or pre-rendering, and not all bots run JavaScript. Keep the article or product copy in the server HTML and load the chat on the client. AI Connect renders a stable checking state on the server, and its Next.js quickstart lazy-loads the panel with ssr: false.