This is a template for building an agent with Next.js, Convex, Better Auth, and LangChain. It includes authentication, real-time database, serverless functions, and an LLM agent with streaming responses.
- Next.js 16 — React framework (App Router) + React 19
- Convex — real-time database & serverless functions
- Better Auth — authentication with Convex adapter
- LangChain + Vercel AI SDK — LLM agent with streaming
npm i
cp .env.local.example .env.local # add OPENAI_API_KEY to .env.local
npm run devSet Convex environment variables (once):
npx convex env set BETTER_AUTH_SECRET=$(openssl rand -base64 32)
npx convex env set SITE_URL http://localhost:3000npm run dev # Run Next.js + Convex in parallel
npm run dev:frontend # Next.js only (port 3000)
npm run dev:backend # Convex only (port 6790)
npm run build # Production build
npm run lint # ESLint- Next.js App: http://localhost:3000
- Convex dashboard: http://localhost:6790