← Back to Leaderboard
Llangchain-ai

langchain-ai/langchain-nextjs-template

A Next.js and LangChain starter for streaming chat, tool use, and document retrieval

Open-Source AI AppQuickstart ↓
Engineering Health (Methodology)
A · 87/100
Maintenance Activity
● Updated yesterday
Latest Release
Rolling commits (main)
Commercial License Check
MIT · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption21/25
Release Cadence11/20
License Clarity20/20
Self-HostedAPI
Total Stars
★ 2,554
24h Growth
+0
7d Growth
+1
Forks
570

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

langchain-ai/langchain-nextjs-template Star History (2023-07-27 - 2026-12-04) ALL-TIME STAR HISTORY (2023-07 – 2026-12) +2.6k in 1226d · avg +2/day 2.7k 1.3k 0 2023-07-27: ★ 12023-10-14: ★ 4202023-12-30: ★ 5842024-03-16: ★ 7672024-06-01: ★ 1,0812024-08-17: ★ 1,2832024-11-02: ★ 1,4312025-01-18: ★ 1,5592025-04-05: ★ 1,7922025-06-21: ★ 1,9472025-09-06: ★ 2,0892025-11-22: ★ 2,2152026-02-07: ★ 2,3402026-04-25: ★ 2,4452026-07-11: ★ 2,4902026-09-26: ★ 2,5262026-12-04: ★ 2,554 ★ 2.6k 2023-07 2025-03 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

This TypeScript starter puts a React chat UI and Next.js App Router API handlers in one application. The editable UI entry point is app/page.tsx; basic model and prompt logic lives in app/api/chat/route.ts. Separate routes demonstrate structured output, agents, and two retrieval designs, so the orchestration patterns can be evaluated without rebuilding the UI. Most examples use the Vercel AI SDK to stream tokens back to the browser.

LangChain.js handles chain composition and LangGraph.js handles agent orchestration. The conversational retrieval chain is composed with LangChain Expression Language; the agent examples use prebuilt helpers that can be replaced by custom graphs. Both retrieval examples share utils/supabase-vector-store.ts, an adapter built on @supabase/supabase-js and @langchain/core around the documents table and match_documents function. Replacing the store means updating the ingestion route and both query routes, not just changing connection settings.

Key Capabilities & Differentiators

The five examples cover basic streaming chat, schema-shaped output, tool-using agents, chain-based RAG, and agent-mediated RAG. The structured-output example converts a Zod schema into an OpenAI function definition and uses function_call to request arguments in that shape. The agent example adds web search through Tavily; its calculator accepts two numbers and an arithmetic operation rather than evaluating arbitrary expressions.

The RAG flow splits source text, embeds the chunks, and uploads them to Supabase before they can be queried. The two retrieval modes let teams compare an explicit chain with a workflow in which the agent can invoke retrieval. OpenAI is the configured provider for the basic examples. Other vector stores can be integrated in code, but changing the model provider or tool set should be treated as an integration task, not as a verified configuration-only switch.

Trade-offs & Limitations

Compared with a Next.js route calling OpenAI directly, this template gives teams several orchestration patterns behind the same UI, at the cost of more libraries and integration surface. If the application only streams a single model response, a direct route or standalone AI SDK integration is simpler. For retrieval, an explicit chain makes the query path easier to reason about; an agent can choose when to retrieve or call tools, but can introduce additional calls and less predictable latency and cost.

Repeated uploads of the same text create duplicates, so recurring ingestion needs a deduplication or replacement strategy. The template is MIT-licensed, but that does not cover provider fees or data terms, and hosting Next.js yourself does not make model inference, search, or managed retrieval offline. For a public deployment, verify authentication, quotas, and per-user data isolation rather than assuming the example routes provide those controls.

Hardware & Deployment Guide

Use Node.js 22 or later. Copy .env.example to .env.local, add an OpenAI API key, install dependencies, and run yarn dev; the local UI is at http://localhost:3000. Add TAVILY_API_KEY for the search agent and a Supabase URL and private key for retrieval. A fresh Supabase instance still needs the documents table and match_documents function; an instance with those objects needs no adapter-specific migration.

Vercel is the documented deployment path, with serverless Edge execution in mind. If using LangSmith tracing there, set LANGCHAIN_CALLBACKS_BACKGROUND=false so tracing can finish before the function exits. The manifest also exposes build and start scripts for a Node-based self-hosting path, but no container recipe is shown. The app server does not host model weights; size it around concurrent streams and ingestion workload and account for external service quotas. No latest GitHub release is listed from which to establish a versioned upgrade history.

API layout: Five separate Next.js routes cover chat, structured output, agents, retrieval chains, and retrieval agents.
Streaming: Most examples use the Vercel AI SDK to deliver generated tokens incrementally to the React client.
Structured output: A Zod schema is converted to an OpenAI function definition, and function_call requests the corresponding arguments.
Agent orchestration: LangGraph.js supplies a prebuilt agent that can be replaced by a custom graph; the search example uses Tavily.
Retrieval contract: A local adapter uses Supabase’s documents table and match_documents function; repeated uploads can create duplicates.
Regression tests: Calculator and mock-backed Supabase tests run on Node.js 22.6+ without API credentials or a live database.
Best For

TypeScript teams prototyping an OpenAI-backed chat app and testing whether structured output, tool use, or Supabase-backed retrieval belongs in the product.

Skip If

You need an offline assistant, a ready-to-operate multi-tenant service, or only a single streaming model call with minimal dependencies.

Reviewed on 2026-11-29 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

Self-HostedAPI
node --experimental-strip-types --test utils/integrations.test.mjs

Comparison vs. Top Chat UI & AI Apps Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
langchain-nextjs-template ★2.6k+1TypeScriptMITA Next.js and LangChain starter for streaming chat, tool use, and document retri
open-design110.9k+1kTypeScriptApache-2.0Local-first design workspace that turns coding-agent output into reviewable prot
openclaw395.6k+570TypeScriptMITA self-hosted Gateway for one AI assistant across chats and devices
OpenBot14.7k+935TypeScriptMITSelf-hosted AG-UI workspace for AI agents with governed browser and tool actions

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/langchain-ai/langchain-nextjs-template.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

langchain-ai/langchain-nextjs-template Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about langchain-nextjs-template

How do the two retrieval examples differ, and where do I swap the vector store?

The template keeps these as separate Next.js API examples. The retrieval chain composes the conversational flow with LangChain Expression Language, while the retrieval agent puts retrieval in a LangGraph.js workflow. Both use the same local Supabase adapter. To replace Supabase, update the ingestion route and both retrieval routes so that indexing and querying stay compatible.

Do I need a GPU, and what determines runtime overhead?

The examples call OpenAI APIs rather than loading model weights locally, so they do not require a GPU or local VRAM. Use Node.js 22 or later for local development. Size the app for concurrent streams and ingestion work, and budget separately for model and embedding calls, Tavily search, and Supabase as applicable.

Can I use the template commercially and host it myself?

The MIT license allows commercial use and modification; retain the copyright and license notices when redistributing the template or substantial portions of it. Self-hosting the Next.js app does not change the terms of external APIs or keep all data on your own infrastructure. Check provider terms and data-handling requirements before sending production content.

When is this preferable to a direct OpenAI or Vercel AI SDK integration?

For a single prompt-and-stream endpoint, a Next.js route calling the model API directly or using only the Vercel AI SDK has fewer orchestration dependencies. Choose this template when you expect to compare chain-based retrieval with agent-mediated retrieval or customize a LangGraph workflow behind the same UI.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining langchain-ai/langchain-nextjs-template? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature langchain-ai/langchain-nextjs-template on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare