Repolode
pgvector

pgvector/pgvector-node

JavaScript and TypeScript helper library that adds pgvector vector type support to Node.js, Deno, and Bun database clients and ORMs.

Stars
445
Forks
24
Open issues
2
Last commit
2 days ago

What is it?

pgvector-node is a small library that lets JavaScript and TypeScript applications store, insert, and query vector embeddings in PostgreSQL through the pgvector extension. It handles converting JavaScript arrays to pgvector's text format and registering the vector types with the database driver, so developers can work with plain number arrays.

The package covers a wide range of database access layers, including node-postgres, Knex.js, Kysely, Sequelize, Prisma, Drizzle ORM, TypeORM, MikroORM, Postgres.js, Slonik, deno-postgres, and Bun SQL. Each integration has its own setup steps for enabling the extension, creating vector columns, inserting data, running nearest-neighbor queries with L2, inner product, or cosine distance, and adding HNSW or IVFFlat indexes.

The repository also includes a SparseVector class for sparse vectors and example projects for common embedding workflows, such as OpenAI and Cohere embeddings, Transformers.js, hybrid search, and bulk loading with COPY.

Key features

  • 01Converts JavaScript arrays to pgvector format and registers vector types with the driver.
  • 02Supports more than a dozen Node.js, Deno, and Bun database libraries and ORMs.
  • 03Provides distance helpers for L2, inner product, cosine, L1, Hamming, and Jaccard in several integrations.
  • 04Includes HNSW and IVFFlat index creation examples.
  • 05Offers a SparseVector class for sparse vector data.

Use cases

  • Building semantic search or retrieval features in a Node.js app backed by PostgreSQL.
  • Storing OpenAI or Cohere embeddings alongside relational data using an existing ORM.
  • Running vector similarity queries from Deno or Bun services.

Quick start

  1. 1

    Install the pgvector package from npm

    npm install pgvector
  2. 2

    Enable the pgvector extension in your database

    await client.query('CREATE EXTENSION IF NOT EXISTS vector');
  3. 3

    Register the vector types on your node-postgres client

    await pgvector.registerTypes(client);

Things to know

  • Requires the pgvector extension to be installed on your PostgreSQL server.

In collections

Topics

FAQ

What is pgvector-node?
JavaScript and TypeScript helper library that adds pgvector vector type support to Node.js, Deno, and Bun database clients and ORMs. pgvector-node is a small library that lets JavaScript and TypeScript applications store, insert, and query vector embeddings in PostgreSQL through the pgvector extension. It handles converting JavaScript arrays to pgvector's text format and registering the vector types with the database driver, so developers can work with plain number arrays.
Is pgvector-node free to use? What license does it have?
pgvector-node is open source under the MIT license. Check the license terms before using it in commercial products.
Is pgvector-node still maintained?
Actively maintained. The last commit to pgvector-node was on Nov 5, 2026.
What can I use pgvector-node for?
Building semantic search or retrieval features in a Node.js app backed by PostgreSQL. Storing OpenAI or Cohere embeddings alongside relational data using an existing ORM. Running vector similarity queries from Deno or Bun services.
How do I install pgvector-node?
Install the pgvector package from npm: npm install pgvector Enable the pgvector extension in your database: await client.query('CREATE EXTENSION IF NOT EXISTS vector'); Register the vector types on your node-postgres client: await pgvector.registerTypes(client);
Where can I get pgvector-node?
The source code and installation instructions are on GitHub: https://github.com/pgvector/pgvector-node

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects