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

@rubixstudios/payload-typesense

v2.1.0

Published

A production-ready search plugin that integrates Typesense with Payload CMS, offering fast, typo-tolerant search with real-time synchronization. This fork by Rubix Studios reduces bloat and introduces targeted changes for improved performance, maintainabi

Readme

Payload CMS + Typesense

A Typesense search plugin for Payload CMS, maintained by Rubix Studios. It provides automatic document synchronisation, configurable search endpoints, optional vector search, and a React search component with customisable themes.

npm version Release

Search interface

Installation

pnpm add @rubixstudios/payload-typesense

Add the plugin to your Payload configuration and specify the collections you want indexed.

// payload.config.ts
import { buildConfig } from 'payload'
import { typesenseSearch } from '@rubixstudios/payload-typesense'

export default buildConfig({
  plugins: [
    typesenseSearch({
      typesense: {
        apiKey: process.env.TYPESENSE_API_KEY!,
        nodes: [
          {
            host: 'localhost',
            port: 8108,
            protocol: 'http',
          },
        ],
      },
      collections: {
        posts: {
          enabled: true,
          searchFields: ['title', 'content'],
          facetFields: ['category', 'status'],
          sortFields: ['title'],
          displayName: 'Blog Posts',
          icon: '📝',
          syncLimit: 500,
        },
      },
      settings: {
        autoSync: true,
        batchSize: 100,
        searchEndpoint: '/search',
      },
    }),
  ],
})

The plugin initialises enabled collections in Typesense and synchronises existing documents during startup. Subsequent document changes and deletions are handled through Payload collection hooks when automatic synchronisation is enabled.

Search configuration

The plugin supports configurable synchronisation, search endpoints, search modes and collection-specific field selection.

| Option | Default | Description | | -------------------------- | --------- | -------------------------------------------------------------------------- | | settings.autoSync | true | Enables startup and document lifecycle synchronisation. | | settings.cache | See below | Search page cache capacity and TTL in milliseconds. | | settings.reconcile | false | Prune stale indexed documents during startup synchronisation. | | settings.batchSize | 100 | Number of documents processed per import batch. | | settings.searchEndpoint | /search | Base path for registered search endpoints, relative to Payload's API path. | | settings.searchMode | keyword | Default search mode. Supports keyword, semantic and hybrid search. | | collections.*.syncLimit | 1000 | Number of Payload documents retrieved per synchronisation page. | | collections.*.sortFields | [] | Additional fields permitted for sorting search results. |

Semantic and hybrid search require vector search to be enabled.

React search components

HeadlessSearchInput and HeadlessSearchDialog provide configurable search interfaces with keyboard navigation, loading states, result callbacks, and custom rendering support.

Both components support the same configuration options. Use HeadlessSearchInput for an inline search interface or HeadlessSearchDialog for a dialog-based search experience.

Search input

'use client'

import { HeadlessSearchInput } from '@rubixstudios/payload-typesense'

export function GlobalSearch() {
  return (
    <HeadlessSearchInput
      baseUrl="http://localhost:3000"
      theme="modern"
      placeholder="Search everything..."
      onResultClick={(result) => {
        console.log('Selected document:', result.document)
      }}
    />
  )
}

Search dialog

'use client'

import { HeadlessSearchDialog } from '@rubixstudios/payload-typesense'

export function GlobalSearch() {
  return (
    <HeadlessSearchDialog
      baseUrl="http://localhost:3000"
      theme="modern"
      placeholder="Search everything..."
      onResultClick={(result) => {
        console.log('Selected document:', result.document)
      }}
    />
  )
}

Collection filtering

Both components search all enabled collections by default. Use the collections prop to restrict results to specific collections.

;<HeadlessSearchInput
  baseUrl="http://localhost:3000"
  collections={['posts', 'products']}
  placeholder="Search posts and products..."
/>

The same configuration applies to HeadlessSearchDialog.

;<HeadlessSearchDialog
  baseUrl="http://localhost:3000"
  collections={['posts', 'products']}
  placeholder="Search posts and products..."
/>

Vector search can also be requested using the vector prop on either component when embedding support is configured.

Custom search endpoints

Both components support a custom searchEndpoint prop. The default endpoint is /api/search.

;<HeadlessSearchInput
  baseUrl="http://localhost:3000"
  searchEndpoint="/api/typesense"
  placeholder="Search everything..."
/>

The endpoint must match the configured plugin search path, including Payload's API prefix.

The same configuration applies to HeadlessSearchDialog.

Features

The plugin supports keyword, semantic and hybrid search across individual or multiple collections, with configurable searchable fields, filtering, sorting, faceting and highlighting through Typesense. Search endpoints include in-memory caching to reduce repeated Typesense requests.

Document synchronisation is handled through Payload hooks, while existing documents are indexed during initialisation using configurable import batches. Optional vector search enables embedding-based queries through supported models and Typesense configuration.

Search results are verified against current publicly accessible Payload documents before being returned. This includes cached results, helping prevent outdated, unpublished, deleted or restricted document content from appearing in search responses.

The included React components provide modern and dark themes, responsive styling, configurable endpoints and custom rendering options without requiring a separate search UI library.

API endpoints

Search endpoints are registered under Payload's /api/search path by default. The base search path can be customised using settings.searchEndpoint.

| Method | Endpoint | Purpose | | ------ | ---------------------------------- | --------------------------- | | GET | /api/search | Search across collections | | GET | /api/search/{collection} | Search a collection | | POST | /api/search/{collection} | Advanced search | | GET | /api/search/{collection}/suggest | Search suggestions | | GET | /api/search/collections | Available collections | | GET | /api/search/health | Health status | | GET | /api/search/health/detailed | Detailed health information |

Requests support pagination and relevant Typesense search parameters. Advanced search requests support filtering, faceting and configurable field selection.

Sorting is restricted to supported built-in fields and fields defined in the collection's sortFields configuration.

Vector search is available through the vector=true query parameter when enabled. The search_mode parameter supports keyword, semantic and hybrid.

Detailed health information requires an explicit healthAccess configuration.

Vector search

Vector search is optional and experimental. Configure an embedding model and the fields used to generate embeddings.

vectorSearch: {
  enabled: true,
  embedFrom: ['title', 'content'],
  embeddingModel: 'azure/text-embedding-ada-002',
  modelConfig: {
    api_key: process.env.EMBEDDING_API_KEY!,
    url: 'https://modelendpoint.com/openai',
  },
},

When embedFrom is omitted, the plugin uses the collection's configured search fields. Embedding model credentials and endpoint settings depend on the selected provider.

To request vector search from the React component, pass vector={true}.

Themes

Two themes are included, modern (default) and dark. Both can be customised using theme configuration options for colours, spacing, typography, shadows, and animations.

const customTheme = {
  theme: 'modern',
  colors: {
    inputBorderFocus: '#10b981',
    inputBackground: '#f0fdf4',
    resultsBackground: '#f0fdf4',
  },
  spacing: {
    inputPadding: '1rem 1.25rem',
    inputBorderRadius: '1.5rem',
  },
  enableAnimations: true,
  enableShadows: true,
}

<HeadlessSearchInput
  baseUrl="http://localhost:3000"
  theme={customTheme}
/>

The component also supports custom class names and rendering callbacks for more control over the search interface.

Reindexing

Startup synchronisation upserts current public documents. To run a controlled reindex from a trusted server-side maintenance task:

import { reindexTypesense } from '@rubixstudios/payload-typesense'

await reindexTypesense(payload, {
  collections: ['posts'],
  prune: true,
})

Omit prune for a non-destructive upsert. Pruning removes indexed documents that are no longer publicly readable or searchable after a successful import and a fresh visibility check. Use it only with dedicated plugin-managed Typesense collections and pause application writes during maintenance. The ID export is held in memory. Set settings.reconcile: true to enable pruning on startup under the same conditions. No collection is dropped or recreated, and failures stop the maintenance operation.

Security

Search indexes are intended for publicly accessible content. Search results are verified against the current published state of documents using Payload's anonymous access controls.

Cached results undergo the same verification process. Documents containing outdated indexed content or restricted fields are excluded until successfully synchronised. Embedding vectors are excluded from search responses.

Pagination, totals, facets and ranking use native Typesense results. Only hits on the requested response page are verified against Payload. There is no plugin-level total result window. Multi-collection searches merge native result pages up to the requested offset, so deeper pages require additional provider requests.

Native aggregate metadata reflects the search index, which can be stale after failed synchronisation or external changes. Keep indexes dedicated to public content and reconcile stale records regularly. A stale or inaccessible hit is omitted from the response, so a page may contain fewer results than requested. search_cutoff, when present, comes from Typesense itself; configured vector candidate limits and provider limits still apply.

Search queries are limited to 512 characters, request URLs to 8,192 characters, and advanced JSON bodies to 32 KiB. Apply a request-body limit at your reverse proxy as well. An optional rateLimit callback must return true to allow a search; otherwise the endpoint returns HTTP 429. Use a shared limiter for multi-instance deployments.

The per-client page cache defaults to 1,000 entries and a five-minute TTL. Configure settings.cache: { maxSize: 1000, ttl: 300000 } or set either value to zero to disable caching. Returned hits are reverified even when their native page is cached.

Configure searchable, sortable and facetable fields to contain only information intended for public search.

Support

For issues, questions, or feature requests, visit GitHub Issues or contact Rubix Studios.

License

Licensed under the MIT License. See LICENSE for details.

Credits

Developed and maintained by Rubix Studios. Based on the original FrontTribe Typesense Search project.