langchain-nextjs-template
Next.js routes for LangChain.js chat, agents, structured output and RAG
Five Next.js API routes that each show one LangChain.js pattern: plain chat, Zod structured output, a prebuilt LangGraph.js agent with Tavily search, and RAG as a chain and as an agent over a Supabase pgvector table. Tokens stream to the client through the AI SDK, routes run on Edge functions, and there is no auth or persistence beyond the vector table. For developers learning LangChain.js who want runnable routes to copy.
Strengths
- Each pattern is one route file you can lift into your own app
- Hosted demo on Vercel
- Mock-backed integration tests run without API keys or a live database
- Supabase adapter reuses the documents table and match_documents function; no migration
Weaknesses
- No auth and no chat history persistence
- OpenAI only out of the box; other providers need code changes
- Re-ingesting the same text duplicates vectors; no dedupe
- Agent and search examples need a Tavily key
- TypeScript, openai, langchain, langgraph, ai-sdk
- Needs openai-api-key, supabase, tavily-api-key
- GitHub template
- env example file