langchain-ai/langchain-nextjs-template
LangChain + Next.js starter template
What it solves
This project provides a ready-to-use starter template for developers who want to build AI-powered applications using LangChain.js and Next.js. It eliminates the need to set up boilerplate code for common AI patterns, such as streaming chat interfaces, structured data extraction, and retrieval-augmented generation (RAG).
How it works
The template integrates LangChain.js with Next.js serverless Edge functions. It uses Vercel's AI SDK to stream tokens to the client in real-time. The backend logic is organized into API routes that implement different AI capabilities:
- Simple Chat: A basic LLM conversation.
- Structured Output: Uses Zod schemas and OpenAI Functions to force the model to return data in a specific format.
- Agentic Workflows: Employs LangGraph.js to create agents that can use tools like web search (Tavily) and a calculator.
- RAG: Combines a vector store (Supabase) with LangChain Expression Language (LCEL) to retrieve relevant documents and answer questions with citations.
Who it’s for
Web developers and AI engineers who want to quickly prototype or deploy AI applications using the TypeScript/JavaScript ecosystem and the Vercel platform.
Highlights
- Multi-pattern Showcase: Includes implementations for simple chat, structured output, RAG, and agents.
- Agentic Framework: Integrates LangGraph.js for building complex, multi-step AI workflows.
- Edge-Ready: Optimized for serverless Edge functions with a small bundle size.
- Vector Store Integration: Pre-configured adapter for Supabase to handle document embedding and retrieval.
- Streaming Support: Built-in support for streaming responses via the Vercel AI SDK.
Related
- Project
- Project
- Project
- Project
- Project