Resources10 min readby Minnie

The 5 Best Next.js RAG and Chat-With-Your-Documents Templates in 2026

The Next.js RAG and document-chat templates worth using in 2026, compared honestly - working retrieval pipelines with minimal UI versus a full product UI you connect to your own pipeline - with what each needs to run and the license terms.

"Chat with your documents" apps all run on the same idea - retrieval-augmented generation, or RAG: split documents into chunks, embed them as vectors, find the chunks most similar to a question, and hand those to a model to answer from. The templates for building one split into two very different halves. Some are working pipelines - ingestion, embeddings, a vector store, a model - wrapped in a minimal demo UI. Others are a finished product UI - document library, citations, billing - over a simulated pipeline you replace. Knowing which half you're buying is most of the decision. This is an honest comparison of five, one of them ours.

What to check before you pick one

  • Real pipeline or simulated - does it actually ingest, embed, and retrieve, or demo those steps on sample data?
  • Vector store - pgvector in your existing Postgres, Supabase, Pinecone, or a cloud search service. One fewer service is one fewer bill.
  • Citations - can a user see exactly which passage an answer came from? It's the difference between an answer they trust and one they double-check.
  • Multi-tenant isolation - if customers share the app, retrieval must never return one workspace's documents to another.
  • Version currency and license - AI libraries move fast; check package.json for current AI SDK and LangChain versions, and check the license before reusing code.

The 5 best Next.js RAG templates in 2026

1. LangChain Next.js Template - Best free, current RAG pipeline

LangChain's official Next.js template is the most current open-source option we found: MIT-licensed, actively maintained, and on Next.js 16 with AI SDK 7 and LangChain 1.x. It's a set of working examples rather than a product - including a retrieval chain and a retrieval agent built with LangGraph.js - backed by Supabase as the default vector store, with the code showing how to swap in other supported stores. You'll need an OpenAI key and Supabase credentials. Use it to get a real pipeline running and understand it; expect to build the product UI yourself.

2. Marginalia - Best product UI for a document-chat SaaS

Marginalia is ours, and it's the other half: the complete product around a RAG pipeline. Eleven routes cover a marketing site that demos the chat, pricing, login, signup, and onboarding, and the signed-in app: a workspace overview, a document library where uploads move through queued, processing, and ready states, a source viewer, settings for profile, workspace, and members, billing with plans, usage, and invoices, and the citation-linked chat itself. Its signature is citation-as-source-preview: hover a citation and a synced source panel scrolls to and highlights the exact quoted passage and page. The design pairs a Fraunces display face with Geist and Geist Mono for citations, with flash-free light and dark mode, on Next.js 16, React 19, and Tailwind v4, with every route checked against WCAG 2.2 AA.

The honest tradeoff is a big one: Marginalia runs in demo mode. Documents, retrieval, and answers come from a seeded sample corpus, ingestion is simulated so you can watch the states change, answers stream word by word from the demo data, and auth and billing are mocked - so it runs with no database or keys, and no model is called. Going live is real backend work, documented in six steps: provision Postgres with pgvector, build ingestion (store the file, chunk, embed, insert vectors), replace the retrieval helper with a similarity search scoped to the workspace so it never crosses tenants, stream answers with the AI SDK, and connect your auth and billing providers. The typed helpers keep the same signatures so the UI doesn't change - but if you want a working pipeline today, start with LangChain's template or PDFToChat and borrow the product.

Marginalia - a chat-with-your-documents SaaS UI: document library with ingestion states, citation-linked chat with a synced source panel, onboarding, settings, and billing. Next.js 16, light and dark, WCAG 2.2 AA tested. From $79, one-time.

See Marginalia

3. PDFToChat - Best open-source end-to-end PDF chat app

PDFToChat, from Nutlope on GitHub, is a complete open-source chat-with-PDF app under the MIT license, on Next.js 16: upload a PDF and chat with it, using Together AI for embeddings and the model, LangChain.js for the RAG logic, Pinecone or MongoDB Atlas as the vector store, Bytescale for file storage, and Clerk for auth. It's one of the most popular projects in this space and it actually works end to end. The caveats: it needs accounts with several services, and while Next.js is current, its AI SDK and LangChain dependencies are a few major versions behind.

4. Azure AI RAG Starter - Best for Azure-based teams

Microsoft's Azure AI RAG starter for Next.js, listed in Vercel's template marketplace, uses Azure AI Search for retrieval and Azure OpenAI for generation, with the AI SDK's useChat hook for streaming responses. It's MIT-licensed and maintained, though it's on Next.js 14. If your organization already runs on Azure, it fits the services you already run; if not, it commits you to Azure's.

5. chatgpt-your-files - Best for learning the pgvector pipeline

Supabase community's chatgpt-your-files is a step-by-step workshop for building secure document chat on Supabase - auth, storage, Postgres with pgvector, and Edge Functions - with each stage on its own git branch. It's one of the clearest ways to learn how a pgvector RAG pipeline fits together. Read it as a learning resource rather than a base to ship: at the time of writing the repository has no license file and no license terms in its README, which means its code isn't licensed for you to reuse.

Get the free template, plus new drops

DocsKit Free lands in your inbox right away. New templates after that.

One email per drop
Unsubscribe anytime
No spam. Ever.

A note on Vercel's RAG starter

Many RAG tutorials still point to vercel-labs/ai-sdk-preview-rag, Vercel's AI SDK RAG example. It was archived in June 2026 and is now read-only, so it won't get fixes or updates. It's still readable as a reference, but start new projects from a maintained template.

Side-by-side comparison

TemplatePipelineVector storeProduct UILicense
LangChain Next.js TemplateRealSupabase (swappable)Minimal examplesMIT
MarginaliaSimulated - six-step guide to go livepgvector (you build it)Full SaaS: library, citations, billingFrom $79
PDFToChatRealPinecone or MongoDB AtlasSimple PDF chat appMIT
Azure AI RAG StarterRealAzure AI SearchMinimal chatMIT
chatgpt-your-filesReal (workshop)Supabase pgvectorSimple appNone - learning only

How to choose

  • You want a free, current, working pipeline to build on - LangChain Next.js Template.
  • You want a working chat-with-PDF app today and don't mind several services - PDFToChat.
  • You're on Azure - the Azure AI RAG Starter.
  • You want to understand pgvector RAG end to end - chatgpt-your-files, as a learning resource.
  • You're building a document-chat SaaS and want the product - library, citations, onboarding, billing - finished, and will build the pipeline - Marginalia.

The pipeline and the product are separable. A practical route is to prove retrieval quality with an open-source pipeline first, then put it behind a finished product UI. Whatever you use, scope every retrieval query to the user's workspace from day one - it's much harder to add after customers have uploaded documents.

Browse every TheKitBase AI SaaS template - Marginalia for document chat, plus AI landing pages and SaaS starter kits. Next.js 16, light and dark, WCAG 2.2 AA tested.

See AI SaaS templates

Get the free template, plus new drops.

Drop your email and we'll send DocsKit Free right away, then ping you the moment a new template goes live - no spam.

One email per drop
Unsubscribe anytime
No spam. Ever.