Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Weaviate Agents

Build and deploy intelligent agents with Weaviate

Weaviate Cloud

Manage and scale Weaviate in the cloud

Additional resources

Academy
Integrations
Contributor guide

Need help?

Weaviate LogoAsk AI Assistant⌘K
Community Forum

JavaScript and TypeScript

JavaScript/TypeScript client (SDK)

The latest TypeScript client is version v3.6.0.

The TypeScript client supports code that is written in TypeScript or JavaScript.

The v3 client is the current TypeScript client. If you have code written for the v2 client, you should migrate it to v3 as it will become deprecated at some point.

The v3 client supports server side development (Node.js hosted). If your application is browser based, you might consider using the TypeScript client v2.

Installation

This section details how install and configure the v3 TypeScript client.

Install the package

The v3 client package has a new name, weaviate-client. Use npm to install the TypeScript client library package:

npm install weaviate-client

Import the Client

The v3 client uses ES Modules. Most of the sample code in the documentation also uses the ES Module style.

If your code requires CommonJS compatibility, use the CommonJS import style:

import weaviate from "weaviate-client";

TypeScript setup

Edit your project's configuration files to make these changes:

  • Add "type": "module" to package.json
  • Add the following code to tsconfig.json
tsconfig.json file
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["src/index.ts"] // this compiles only src/.index.ts, to compile all .ts files, use ["*.ts"]
}

Get started

Prerequisites

If you haven't yet, we recommend going through the Quickstart tutorial first to get the most out of this section.

The following code demonstrates how to:

  1. Connect to a local Weaviate instance.
  2. Create a new collection.
  3. Populate the database using batch import and vectorize the data.
  4. Perform a vector search.
import weaviate, { WeaviateClient, vectorizer } from 'weaviate-client';

const client: WeaviateClient = await weaviate.connectToLocal();

await client.collections.create({
name: 'Question',
vectorizers: vectorizer.text2VecOllama({ // Configure the Ollama embedding integration
apiEndpoint: 'http://host.docker.internal:11434', // Allow Weaviate from within a Docker container to contact your Ollama instance
model: 'nomic-embed-text', // The model to use
}),
});

// Load data
async function getJsonData() {
const file = await fetch(
'https://raw.githubusercontent.com/weaviate-tutorials/quickstart/main/data/jeopardy_tiny.json'
);
return file.json();
}

// Note: The TS client does not have a `batch` method yet
// We use `insertMany` instead, which sends all of the data in one request
async function importQuestions() {
const questions = client.collections.get('Question');
const data = await getJsonData();
const result = await questions.data.insertMany(data);
console.log('Insertion response: ', result);
}

await importQuestions();

const questions = client.collections.get('Question');

const result = await questions.query.nearText('biology', {
limit: 2,
});

result.objects.forEach((item) => {
console.log(JSON.stringify(item.properties, null, 2));
});

client.close(); // Close the client connection

Asynchronous usage

All client v3 methods, with the exception of collection.use(), use ES6 Promises with asynchronous code. This means you have to use .then() after function calls, or wrap your code async/await blocks.

When there is an asynchronous code error, a promise returns the specific error message. If you use async and await, a rejected promises acts like a thrown exception

Releases

Go to the GitHub releases page to see the history of the TypeScript client library releases and change logs.

Click here for a table of Weaviate and corresponding client versions

This table lists the latest five Weaviate Database versions and corresponding client library versions.

Weaviate Database
(GitHub)
First
release date
Python
(GitHub)
TypeScript/
JavaScript
(GitHub)
Go
(GitHub)
Java
(GitHub)
1.31.x2025-05-304.15.x3.6.x5.2.xTBC
1.30.x2025-04-034.12.x3.5.x5.1.x5.2.x
1.29.x2025-02-174.11.x3.4.x5.0.x5.1.x
1.28.x2024-12-114.10.x3.3.x4.16.x5.0.x
1.27.x2024-10-164.9.x3.2.x4.16.x5.0.x
4.9.x
1.26.x2024-07-224.7.x3.1.x4.15.x4.8.x
Older releases
Weaviate Database
(GitHub)
First
release date
Python
(GitHub)
TypeScript/
JavaScript
(GitHub)
Go
(GitHub)
Java
(GitHub)
1.25.x2024-05-104.6.x2.1.x4.13.x4.6.x
1.24.x2024-02-274.5.x2.0.x4.10.x4.4.x
1.23.x2023-12-183.26.x1.5.x4.10.x4.4.x
1.22.x2023-10-273.25.x1.5.x4.10.x4.3.x
1.21.x2023-08-173.22.x1.4.x4.9.x4.2.x
1.20.x2023-07-063.22.x1.1.x4.7.x4.2.x
1.19.x2023-05-043.17.x1.1.x14.7.x4.0.x
1.18.x2023-03-073.13.x2.14.x4.6.x3.6.x
1.17.x2022-12-203.9.x2.14.x4.5.x3.5.x
1.16.x2022-10-313.8.x2.13.x4.4.x3.4.x
1.15.x2022-09-073.6.x2.12.x4.3.x3.3.x
1.14.x2022-07-073.6.x2.11.x4.2.x3.2.x
1.13.x2022-05-033.4.x2.9.x4.0.x2.4.x
1.12.x2022-04-053.4.x2.8.x3.0.x2.3.x
1.11.x2022-03-143.2.x2.7.x2.6.x2.3.x
1.10.x2022-01-273.1.x2.5.x2.4.x2.1.x
1.9.x2021-12-103.1.x2.4.x2.4.x2.1.x
1.8.x2021-11-303.1.x2.4.x2.3.x1.1.x
1.7.x2021-09-013.1.x2.4.x2.3.x1.1.x
1.6.x2021-08-112.4.x2.3.x2.2.x1.0.x
1.5.x2021-07-132.2.x2.1.x2.1.x1.0.x
1.4.x2021-06-092.2.x2.1.x2.1.x1.0.x
1.3.x2021-04-232.2.x2.1.x2.1.x1.0.x
1.2.x2021-03-152.2.x2.0.x1.1.x-
1.1.x2021-02-102.1.x---
1.0.x2021-01-142.0.x---

TypeScript client change

The TypeScript client replaced the JavaScript client on 2023-03-17.

Migrating from v2 to v3

If you are migrating a project from the Weaviate TypeScript client v2 to the v3 client, see the migration page for additional details.

Code examples & further resources

Usage information for various operations and features can be found throughout the Weaviate documentation.



The Weaviate API reference pages for search and REST may also be useful starting points.

Questions and feedback

If you have any questions or feedback, let us know in the user forum.