npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@payloadcms-vectorize/cf

v0.7.1

Published

Cloudflare Vectorize adapter for payloadcms-vectorize

Downloads

289

Readme

@payloadcms-vectorize/cf

Cloudflare Vectorize adapter for payloadcms-vectorize. Enables vector search capabilities using Cloudflare Vectorize.

Prerequisites

  • Cloudflare account with Vectorize index configured
  • Payload CMS 3.x with any supported database adapter
  • Node.js 18+

Installation

pnpm add @payloadcms-vectorize/cf payloadcms-vectorize

Quick Start

1. Create Vectorize Index

Create a Vectorize index in your Cloudflare dashboard or via Wrangler:

wrangler vectorize create my-vectorize-index --dimensions=384 --metric=cosine

2. Configure the Plugin

import { buildConfig } from 'payload'
import { postgresAdapter } from '@payloadcms/db-postgres'
import { createCloudflareVectorizeIntegration } from '@payloadcms-vectorize/cf'
import payloadcmsVectorize from 'payloadcms-vectorize'

// Create the integration
const integration = createCloudflareVectorizeIntegration({
  config: {
    default: {
      dims: 384, // Vector dimensions (must match your embedding model and Vectorize index)
    },
  },
  binding: env.VECTORIZE, // Cloudflare Vectorize binding
})

export default buildConfig({
  // ... your existing config
  db: postgresAdapter({
    pool: {
      connectionString: process.env.DATABASE_URL,
    },
  }),
  plugins: [
    payloadcmsVectorize({
      dbAdapter: integration.adapter,
      knowledgePools: {
        default: {
          collections: {
            posts: {
              toKnowledgePool: async (doc) => [{ chunk: doc.title || '' }],
            },
          },
          embeddingConfig: {
            version: 'v1.0.0',
            queryFn: embedQuery,
            realTimeIngestionFn: embedDocs,
          },
        },
      },
    }),
  ],
})

Configuration

The createCloudflareVectorizeIntegration function accepts a configuration object with config and binding properties:

const integration = createCloudflareVectorizeIntegration({
  config: {
    poolName: {
      dims: number, // Required: Vector dimensions
    },
    // ... additional pools
  },
  binding: vectorizeBinding, // Required: Cloudflare Vectorize binding
})

Configuration Options

| Option | Type | Required | Description | | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | dims | number | Yes | Vector dimensions for the Vectorize index. Must match your embedding model's output dimensions and your Cloudflare Vectorize index configuration. |

Cloudflare Bindings

| Property | Type | Required | Description | | ----------- | ---------------- | -------- | ------------------------------------------------------------------------------------------------- | | vectorize | VectorizeIndex | Yes | Cloudflare Vectorize binding for vector storage. Configured in wrangler.toml for Workers/Pages. |

Integration Return Value

createCloudflareVectorizeIntegration returns an object with:

| Property | Type | Description | | --------- | ----------- | ------------------------------------------------------------------------- | | adapter | DbAdapter | The database adapter to pass to payloadcmsVectorize({ dbAdapter: ... }) |

Multiple Knowledge Pools

You can configure multiple knowledge pools with different dimensions:

const integration = createCloudflareVectorizeIntegration({
  config: {
    documents: {
      dims: 1536,
    },
    images: {
      dims: 512,
    },
  },
  binding: env.VECTORIZE,
})

export default buildConfig({
  // ...
  plugins: [
    payloadcmsVectorize({
      dbAdapter: integration.adapter,
      knowledgePools: {
        documents: {
          collections: {
            /* ... */
          },
          embeddingConfig: {
            /* ... */
          },
        },
        images: {
          collections: {
            /* ... */
          },
          embeddingConfig: {
            /* ... */
          },
        },
      },
    }),
  ],
})

Note: Each knowledge pool requires a separate Vectorize index with matching dimensions.

Using with Cloudflare AI

export const embedDocs = async (texts: string[]): Promise<number[][]> => {
  const results = await Promise.all(
    texts.map((text) =>
      env.AI.run('@cf/baai/bge-small-en-v1.5', {
        text,
      }),
    ),
  )
  return results.map((r) => r.data[0])
}

export const embedQuery = async (text: string): Promise<number[]> => {
  const result = await env.AI.run('@cf/baai/bge-small-en-v1.5', {
    text,
  })
  return result.data[0]
}

Using with Voyage AI

import { embed, embedMany } from 'ai'
import { voyage } from 'voyage-ai-provider'

export const embedDocs = async (texts: string[]): Promise<number[][]> => {
  const embedResult = await embedMany({
    model: voyage.textEmbeddingModel('voyage-3.5-lite'),
    values: texts,
    providerOptions: {
      voyage: { inputType: 'document' },
    },
  })
  return embedResult.embeddings
}

export const embedQuery = async (text: string): Promise<number[]> => {
  const embedResult = await embed({
    model: voyage.textEmbeddingModel('voyage-3.5-lite'),
    value: text,
    providerOptions: {
      voyage: { inputType: 'query' },
    },
  })
  return embedResult.embedding
}

Known Limitations

Metadata Filtering

The CF adapter uses Cloudflare Vectorize's native metadata filtering, which applies filters before the topK selection. This means filtering works correctly with the result limit for most operators.

Natively supported operators (applied before topK — correct result counts):

  • equals, not_equals, in, notIn
  • greater_than, greater_than_equal, less_than, less_than_equal

Post-filtered operators (applied after topK — may return fewer results than requested):

  • like, contains, exists

Vectorize Constraints

| Constraint | Limit | |---|---| | topK maximum | 100 (or 20 when returning metadata) | | String metadata indexing | First 64 bytes only (truncated at UTF-8 boundaries) | | Filter object size | Under 2048 bytes JSON-encoded | | Range query accuracy | May be reduced on ~10M+ vectors |

Metadata indexes must exist before vectors are inserted for filtering to work.

OR Queries

Cloudflare Vectorize does not support OR at the filter level. All or clauses are evaluated as post-filters, subject to the topK constraint.

License

MIT