Skip to content

Guide · Open source

How to use langchainjs: install, set up and build your first app

Updated · written with AI from the project's own documentation and checked against our catalogue data

LangChain.js is a TypeScript framework for building applications powered by large language models (LLMs). It gives you a standard interface for models, embeddings, vector stores and tools, so you can connect an AI model to your own data and systems. This guide shows you how to install it, what it runs on, and where it fits, so you can decide whether to start building with it.

LangChain.jslangchain-ai/langchainjs · ★ 18.3k · MIT

Quick start

  1. 1Check your Node.js version. Confirm you have Node.js 20.x, 22.x or 24.x installed before you start.
  2. 2Install the package. Run npm install -S langchain, or use pnpm install langchain or yarn add langchain.
  3. 3Read the Getting started guide. Open the official docs at docs.langchain.com and follow the installation and environment setup steps.
  4. 4Set up your environment. Follow the environment setup section in the docs so your project can reach the model provider you choose.
  5. 5Run a simple example. Start with one of the simple examples in the docs to confirm the setup works.
  6. 6Add your own data or tools. Connect the model to your data sources, vector stores or tools using the standard interfaces.

What langchainjs is and who it is for

LangChain describes itself as a framework for building LLM-powered applications. It helps you chain together interoperable components and third-party integrations, and aims to keep your decisions workable as the underlying technology changes.

LangChain.js is the JavaScript and TypeScript version. It is the counterpart of the Python LangChain library.

  • JavaScript or TypeScript developers building LLM-powered features
  • Teams that want to switch between model providers without rewriting code
  • Developers connecting AI models to external data sources and APIs
  • Projects that need to run in Node.js, browsers or edge runtimes

Install langchainjs with npm, pnpm or yarn

Install LangChain.js with the package manager you already use. The README lists these three options. Node.js 20.x, 22.x or 24.x is required.

  • npm: install it with the -S flag
  • pnpm: install it with the add-style command below
  • yarn: use the add command below
npm install -S langchain pnpm install langchain yarn add langchain

Know where langchainjs runs

LangChain.js is written in TypeScript. The README lists these environments where it can be used. Node.js supports both ESM and CommonJS.

If you plan to deploy to a serverless or edge platform, check that your target is on this list before you commit to the design.

  • Node.js (ESM and CommonJS), versions 20.x, 22.x and 24.x
  • Cloudflare Workers
  • Vercel / Next.js (Browser, Serverless and Edge functions)
  • Supabase Edge Functions
  • Browser
  • Deno
  • Bun

Understand the main building blocks

The main value of LangChain.js is its standard interface. You work with models, embeddings, vector stores, tools and agents through shared abstractions, so swapping one provider for another is less work than rewriting the app.

The library also works at different levels of abstraction. You can use high-level chains for quick starts or low-level components for finer control. For more advanced agent orchestration, the README points to LangGraph.js.

  • Models and embeddings: a common interface across providers
  • Vector stores and retrievers: connect the model to your own data
  • Tools and toolkits: let the model call external systems and APIs
  • Integrations: the README points to a provider list in the docs

Find the documentation and extra help

The official documentation covers installation, environment setup and simple examples under Getting started. The Learn section explains core concepts. The README also links to a community forum and a docs chat tool.

For a managed platform to test, monitor and deploy apps, the README points to LangSmith. Deep Agents is a higher-level package built on LangChain for agents with planning, subagents and file system use.

  • Getting started: installation, environment setup, simple examples
  • Learn: core concepts of LangChain
  • LangChain Forum: questions, ideas and feedback
  • Chat LangChain: ask questions about the documentation

What people use it for

  • Building a chatbot or assistant inside a TypeScript web app
  • Connecting an AI model to your own documents through vector stores and retrievers
  • Letting a model call external APIs through tools
  • Switching from one model provider to another without rewriting the app
  • Running LLM features in a browser, on Vercel or in Cloudflare Workers

Frequently asked questions

Is langchainjs free to use?

LangChain.js is released under the MIT licence, which is an open-source licence. Check the LICENSE file in the repository for the full terms. Model provider APIs you connect to may charge their own fees.

What do I need to install langchainjs?

You need Node.js 20.x, 22.x or 24.x. Install the library with npm install -S langchain, pnpm install langchain or yarn add langchain.

Can I use langchainjs in the browser?

The README lists the browser as a supported environment, along with Node.js, Deno, Bun, Cloudflare Workers, Vercel and Supabase Edge Functions.

Is there a Python version of LangChain?

Yes. The README says LangChain has an equivalent Python library. If you do not use JavaScript or TypeScript, the README suggests using the Python library instead.

Is langchainjs a no-code tool?

No. It is a developer library and requires writing code in JavaScript or TypeScript.

What are the alternatives to langchainjs?

Comparable projects include LlamaIndex.TS, Vercel AI SDK and Mastra. If you only need a single direct call to one model API, a framework like this may add more layers than you need.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

LangChain.js suits JavaScript or TypeScript developers who want a standard interface for models, data and tools, and who may need to switch providers later. It is not a good fit for people who do not write code, or for projects that only make one direct call to a single model API, where a framework adds unnecessary layers.

Install options & downloads