Show HN: Turn any Next.js app AI native in 5 minutes
BetterAgent is a CLI-driven tool that quickly adds an AI agent layer to Next.js apps, enabling agents to interact with routes and server actions. It offers zero-config DX, embeddable UI components, built-in observability, and production-grade infrastructure including auth forwarding, streaming, and rate limiting.
The agent layer your SaaS is missing.
Point BetterAgent at your codebase. It reads your routes and server actions - and now your users get an agent that does real work inside the product you already shipped.
CLI-driven setup·500 free credits / mo·shadcn-compatible·Next.js
~/cohort-app · zshrunning
COcohort · campaigns assistantlive
▌
Three primitives
Routes, server actions, client actions. Same protocol.
Three primitives in your code; two messages on the wire. The agent reads data through routes, mutates through server actions, and steers the UI through client actions.
server-actions.betteragent.ts
"use server";
import { defineServerAction } from "betteragent-next"; import { z } from "zod"; import { createCampaign } from "@/app/actions";
export const createCampaignAction = defineServerAction({ name: "createCampaign", description: "Draft a re-engagement campaign.", schema: z.object({ audienceId: z.string() }), handler: createCampaign, });
Server Action
Wrap an existing Next.js Server Action — the SDK dispatches the call so session and revalidation work as normal.
Forwards your end-user bearer token to your APIs.
Hard caps & observability included.
Read the docs
Zero-config DX
Your app already has tools. BetterAgent finds them.
Point the CLI at your codebase and we read your routes and server actions. You pick which handlers the agent can call and write the descriptions it uses to decide when.
~/cohort-app · zshrunning
01
betteragent discover
We walk your codebase: every Server Action, every API route, every exported handler. You pick which ones the agent can call.
02
Tool files scaffolded
We scaffold one entry per selected handler with an empty Zod schema you fill in. The agent gets the same contract your IDE has once you describe the arguments.
03
betteragent sync
Diff against the server, confirm, ship. Routes are static at runtime — the LLM only sees the names and schemas you approved.
Components, not chatbots
A shadcn-style registry of agent UI.
Pick a layout, run betteragent add, and you own the code. Theming inherits from your shadcn tokens.
COcohort
Launch re-engagement campaign.
→create_campaign
Drafted for 4,820 subscribers.
Ask…→
chat-sidebarPersistent panel inside a split layout. Survives navigation.npx betteragent add sidebar
COcohort
Launch re-engagement campaign.
→create_campaign
Drafted for 4,820 subscribers.
Ask…→
chat-popupSmall bubble that expands into a full conversation. Great for marketing pages.npx betteragent add chat-popup
COcohort
Launch re-engagement campaign.
→create_campaign
Drafted for 4,820 subscribers.
Ask…→
inline-barEmbedded in your page like a comment thread. No portal, no modal.npx betteragent add inline-bar
launch campaign for inactive 30d⌘K
Run agent on selection↩
Open recent run↗
Tools · 4→
cmd-kCommand-bar interface. Press ⌘K, type a question, ship work.npx betteragent add cmd-k
Browse the full registry
Observability built in
Debug like an HTTP request, not a model.
Every conversation, every tool call, every token, all recorded and queryable.
cohort-mail / cohort-prod / runsapp.betteragent.dev
Runs (24h)1,284+18% vs y'day
Avg latency2.41sp95: 4.8s
Tool calls4,012list_audiences top
Spend (mo)$148$0.0114 / run
id
status
route
tools
tokens
latency
started
run_8a91f3running/api/agent/campaigns2612—just now
run_8a91f0done/api/agent/campaigns41,2843.2s12s ago
run_8a91ebdone/api/agent/audiences14120.9s1m ago
run_8a91e8failed/api/agent/analytics290130.0s4m ago
run_8a91e2done/api/agent/campaigns52,1404.8s7m ago
Built for production
Boring infrastructure for an exciting layer.
Streaming, observability, billing, auth, rate-limits, evals. The unsexy stuff that decides whether your agent ships.
Auth that's already there
Forwards your end-user's bearer token to your APIs. No service accounts, no scope leaks.
AR[email protected]campaigns:write
const { user } = auth()
// agent runs as the signed-in user
createCampaign({ user_id: "u_92ab" })
✓ No service accounts · No scope leaks
Native SSE streaming
Tool calls fire mid-stream. No polling, no batching.
…
Claude Sonnet 4.6
Default model. Hosted with cache hits at 10% of normal token cost.
claude-sonnet-4.6· live on every plan
claude-haiku-4.5· coming soon
claude-opus-4.5· coming soon
Hosted · cache hits at 10%
Observable by default
Every run, every token, every tool call logged and queryable.
p50 latency1.84s
p95 latency4.8s
error rate0.42%
One protocol, Next.js today
Next.js (App Router) is the only framework supported right now. Other adapters are planned, not yet available.
Next.jsSHIPPED
Vueplanned
Svelteplanned
Remixplanned
Expressplanned
Honoplanned
Rate limiting built in
Per-project and per-IP limits enforced before requests hit your tools.
u_92ab · /v1/chat14/20 req/min
per end-user
20 msg / min
signup guard
5 req / 15min
Pricing
Free until your agent earns its keep.
500 credits every 30 days on the house, free to prototype. Starter is $0.99/mo for 1,500 credits. No card required.
Free
$0/mo
For prototyping and small projects.
500 credits / 30 days
Unlimited projects
Hosted Sonnet 4.6
StarterPOPULAR
$0.99/mo
3x the runway, for less than a pack of gum.
1,500 credits / 30 days
Hard-capped, no surprise charges
Hosted Sonnet 4.6
Plus
$14.99/mo
For agents that need a little more room.
4,000 credits / 30 days
$10 per 1,000 additional credits
Bring your own API key for unlimited usage
Hosted Sonnet 4.6
Enterprise
Custom
Custom plans for teams shipping at scale.
Every plan is priced per project — create as many projects as you want.
Need more credits to mess around?Send us a message
5 minutes to a working agent
Stop describing what your app does. Let it do the work.
Free forever for prototypes. Plug in your routes, drop in the components, ship a real agent before lunch.
Get started — freeRead the quickstart
No credit card·500 free credits·Works with Next.js