LangChain vs n8n and CrewAI: LangChain.js, tutorials, popularity, speed, chat history

What LangChain.js is with an example, beginner tutorials, why LangChain is popular and sometimes slow, LangChain vs n8n and CrewAI, and chat history in Next.js.

In a packed college auditorium
In a packed college auditorium

Key takeaways

  • LangChain.js is the JavaScript and TypeScript version of LangChain for building LLM apps in Node, Next.js and edge runtimes.
  • Start with official tutorials: a chat model call, a prompt template, a RAG chain, then an agent with LangGraph.
  • LangChain is popular for its integrations and patterns; slowness usually comes from model calls, not the framework.
  • LangChain is a code library; n8n is a visual workflow platform; CrewAI is a framework for role-based multi-agent teams.
  • Store chat history in a database keyed by session ID; legacy chains are replaced by LangGraph and message history tools.

LangChain.js is the JavaScript and TypeScript edition of LangChain, a framework for building applications with language models: chat model wrappers, prompts, retrievers, tools and agents, usable in Node.js, Next.js and edge runtimes. Comparing it with n8n and CrewAI is really comparing a code library, a visual workflow platform and a multi-agent framework. I build AI products with Next.js and FastAPI, so this page covers LangChain.js with an example, tutorials, its popularity and speed, comparisons, and storing chat history in Next.js.

What is LangChain.js?

LangChain.js is the JavaScript version of LangChain, offering the same core concepts as the Python library: chat models, prompt templates, output parsers, document loaders, text splitters, vector stores, retrievers, tools and agents, with integrations for many providers.

Also asked as: what is langchain js

It suits web developers building AI features in Next.js, Express or serverless functions, where Python is not part of the stack. Packages are modular: @langchain/core for interfaces, provider packages such as @langchain/openai or @langchain/anthropic, and LangGraph.js for stateful agents. Some integrations available in Python may be missing or newer in JavaScript, so check the documentation for what you need.

What is a LangChain.js example?

A minimal chain combines a prompt template with a chat model using pipe, then invokes it with variables.

Also asked as: langchain js example

import { ChatOpenAI } from "@langchain/openai";
import { ChatPromptTemplate } from "@langchain/core/prompts";

const prompt = ChatPromptTemplate.fromMessages([
  ["system", "Answer in two sentences."],
  ["human", "{question}"],
]);
const chain = prompt.pipe(new ChatOpenAI({ model: "gpt-4o-mini" }));
const res = await chain.invoke({ question: "What is RAG?" });
console.log(res.content);

Install with npm install @langchain/core @langchain/openai and set your API key as an environment variable. Swap the model class to use another provider with the same chain.

What is a good LangChain tutorial for beginners?

Start with the official LangChain tutorials for your language: they cover calling chat models, prompt templates, structured output, building a RAG app and building agents, using current interfaces. LangChain Academy offers free courses, especially on LangGraph.

Also asked as: langchain tutorial github

A beginner sequence:

  • Call a chat model and stream the response.
  • Use prompt templates and parse structured output.
  • Load a document, split it, embed it and retrieve from it.
  • Build a RAG chain that cites sources.
  • Add a tool and build a small agent with LangGraph.
  • Trace runs to see exactly what the model receives.

Build one small project end to end rather than following many partial tutorials.

Where can I find LangChain tutorials on GitHub?

The LangChain and LangChain.js repositories on GitHub include documentation source and examples, and LangChain's organisation hosts templates and courses such as "RAG From Scratch" notebooks. Community repositories collect projects and integration examples.

When using GitHub examples, check the last update date and package versions, because LangChain's interfaces changed significantly over 2023 to 2025, and older examples use deprecated classes. Prefer examples that match your installed versions, or upgrade carefully. Read the code rather than just running it; understanding how chains and retrievers connect is what lets you debug your own app later.

What is the best LangChain tutorial according to the community?

Community threads, such as on Reddit, commonly recommend official documentation and LangChain Academy over older video tutorials, and many suggest learning the underlying model APIs directly first to understand what LangChain abstracts away.

Also asked as: best langchain tutorial reddit

Common advice: avoid tutorials from 2023 that use legacy chains; learn LangGraph for agents; use tracing to see prompts; and do not add LangChain to simple apps that only call one model. Some developers prefer lighter libraries or direct SDK calls for production. A balanced approach is to learn LangChain's concepts, use it where its integrations save time, and keep critical logic understandable.

LangChain became popular because it arrived early, in late 2022, just as developers rushed to build with language models, and it offered ready-made patterns for RAG, agents and memory plus hundreds of integrations with models, vector stores and tools.

Its common interfaces let developers swap providers easily, and a large community produced tutorials, templates and answers. LangGraph added controllable agent workflows, and LangSmith added tracing and evaluation. Criticism exists too: abstraction layers can make debugging harder, and fast-changing interfaces frustrated early users. Its popularity reflects convenience and ecosystem rather than being the only good way to build.

Why is LangChain so slow?

Usually it is not LangChain itself but what the app does: sequential model calls, large prompts, slow retrieval, many agent steps, or no streaming. Framework overhead is small compared with network calls to models and databases.

To speed things up:

  • Stream responses so users see output immediately.
  • Run independent steps in parallel instead of sequentially.
  • Reduce agent steps and use smaller models for simple decisions.
  • Cache embeddings and repeated responses.
  • Retrieve fewer, better chunks to shorten prompts.
  • Measure each step with tracing to find the real bottleneck.

If import time or bundle size matters, import only the packages you need.

LangChain vs n8n: which should I use?

LangChain is a code library for building LLM logic inside your application. n8n is a visual workflow automation platform that connects apps with triggers and actions, including AI agent nodes built on LangChain concepts. Use LangChain for custom AI applications; use n8n for automating business processes across tools.

If you are building a product feature, such as a RAG chatbot inside your web app, LangChain or direct SDKs fit. If you are automating operations, such as routing emails, updating CRMs and notifying teams, n8n is faster to build and easier for non-developers to maintain. Many teams use both: n8n workflows calling a custom API that uses LangChain internally.

LangChain vs n8n vs CrewAI: what are the differences?

LangChain is a general framework for LLM apps; n8n is a low-code automation platform; CrewAI is a Python framework for orchestrating teams of role-based agents that collaborate on tasks, such as a researcher agent and a writer agent.

Choose CrewAI when your problem maps naturally onto multiple specialised agents working together and you want a simple, opinionated structure. Choose LangGraph, from the LangChain ecosystem, when you need fine control over agent state and flow. Choose n8n when the main challenge is integrating many apps with reliable triggers and retries. For many tasks, a single well-designed agent or plain workflow beats a multi-agent setup on cost and reliability.

How do I store chat history with LangChain in a Next.js app?

Store messages in a database, keyed by a session or conversation ID, and load them for each request. The older ConversationalRetrievalQAChain is legacy; current LangChain.js uses message history utilities or LangGraph with a checkpointer to persist conversation state.

Also asked as: how to store chat history using langchain conversationalretrievalqa chain in a next js app

A practical setup: when a user sends a message, a Next.js route handler loads previous messages for that conversation from your database, rewrites the follow-up question into a standalone query, retrieves documents, generates the answer, and saves both messages back. Use a store such as PostgreSQL or Redis, not in-memory variables, because serverless functions do not keep memory between requests. Limit history length or summarise older turns to control prompt size.

Sources

  1. LangChain.js, documentationjs.langchain.com
  2. LangChain, Python documentationpython.langchain.com
  3. LangGraph, documentationlangchain-ai.github.io
  4. n8n Docsdocs.n8n.io
  5. CrewAI, documentationdocs.crewai.com
  6. LangChain.js, repositorygithub.com
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on RAG & retrieval

All RAG & retrieval guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India