rubix-studios-pty-ltd

payload typesense

by rubix-studios-pty-ltd
Search
v3
v4
^3.94.2 || ^4.0.0-beta.12
MIT

Overview

Summary generated from the README

Integrates Typesense with Payload to index selected collections and keep them in sync through collection hooks, with startup synchronisation in configurable batches. It registers search endpoints for single and multi-collection queries, suggestions and health checks. Keyword, semantic and hybrid modes are supported, and vector search is optional and requires an embedding model. Results are verified against Payload's public access rules before being returned.

Features

  • Automatic document sync on create, update and delete, plus startup import in batches
  • Search, advanced search, suggestion, collections and health endpoints
  • Keyword, semantic and hybrid search modes with optional vector embeddings
  • Per-collection searchable, facet and sort fields with highlighting
  • In-memory page cache with configurable size and TTL, and an optional rate limit callback
  • HeadlessSearchInput and HeadlessSearchDialog React components with modern and dark themes

Use cases

  • Add typo-tolerant site search across posts and products in a Payload and Next.js site
  • Expose public content search while excluding unpublished or restricted documents
  • Reindex or prune stale Typesense documents with a server-side maintenance task

From the author

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, maintainability, and flexibility.

Installation

npm i @rubixstudios/payload-typesense

33

Stars

3

Forks

0

Open Issues

Today

Last Updated

1.3k

Weekly Downloads

v2.1.0

npm Version

271.3 KB

Unpacked Size

2

Dependencies

GitHub stars

33+5 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202633
Dec 5, 202633
Dec 4, 202633
Dec 3, 202633
Dec 2, 202633
Dec 1, 202633
Nov 30, 202633
Nov 29, 202633
Nov 28, 202633
Nov 27, 202633
Nov 26, 202633
Nov 25, 202633
Nov 24, 202633
Nov 23, 202633
Nov 22, 202633
Nov 21, 202633
Nov 20, 202633
Nov 19, 202633
Nov 18, 202633
Nov 17, 202633
Nov 16, 202633
Nov 15, 202633
Nov 14, 202633
Nov 13, 202633
Nov 12, 202633
Nov 11, 202633
Nov 10, 202633
Nov 9, 202633
Nov 8, 202633
Nov 7, 202633
Nov 6, 202633
Nov 5, 202633
Nov 4, 202633
Nov 3, 202633
Nov 2, 202633
Nov 1, 202632
Oct 31, 202632
Oct 30, 202632
Oct 29, 202632
Oct 28, 202632
Oct 27, 202632
Oct 26, 202632
Oct 25, 202632
Oct 24, 202632
Oct 23, 202632
Oct 22, 202632
Oct 21, 202632
Oct 20, 202632
Oct 19, 202632
Oct 18, 202632
Oct 17, 202632
Oct 16, 202632
Oct 15, 202632
Oct 14, 202632
Oct 13, 202630
Oct 12, 202630
Oct 11, 202629
Oct 10, 202629
Oct 9, 202628
Oct 8, 202628
Oct 7, 202628
Oct 6, 202628
Oct 5, 202628
Oct 4, 202628
Oct 3, 202628
Oct 2, 202628
Oct 1, 202628
Sep 30, 202628
Sep 29, 202628
Sep 28, 202628
Sep 27, 202628
Sep 26, 202628
Sep 25, 202628
Sep 24, 202628
Sep 23, 202628
Sep 22, 202628
Sep 21, 202628
Sep 20, 202628
Sep 19, 202628
Sep 18, 202628
Sep 17, 202628
Sep 16, 202628
Sep 15, 202628
Sep 14, 202628
Sep 13, 202628
Sep 12, 202628
Sep 11, 202628
Sep 10, 202628
Sep 9, 202628
Sep 8, 202628
Sep 7, 202628
npm weekly downloads

1.3K+943 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 20261,339
Dec 5, 20261,285
Dec 4, 20261,538
Dec 3, 20261,446
Dec 2, 20261,193
Dec 1, 20261,144
Nov 30, 20261,348
Nov 29, 20261,295
Nov 28, 20261,281
Nov 27, 2026964
Nov 26, 2026758
Nov 25, 2026771
Nov 24, 2026796
Nov 23, 2026582
Nov 22, 2026586
Nov 21, 2026715
Nov 20, 2026848
Nov 19, 2026796
Nov 18, 2026828
Nov 17, 2026730
Nov 16, 2026728
Nov 15, 2026701
Nov 14, 2026556
Nov 13, 2026530
Nov 12, 2026604
Nov 11, 2026729
Nov 10, 2026788
Nov 9, 2026785
Nov 8, 2026778
Nov 7, 2026735
Nov 6, 2026577
Nov 5, 2026505
Nov 4, 2026304
Nov 3, 2026235
Nov 2, 2026219
Nov 1, 2026226
Oct 31, 2026238
Oct 30, 2026263
Oct 29, 2026230
Oct 28, 2026199
Oct 27, 2026254
Oct 26, 2026278
Oct 25, 2026255
Oct 24, 2026239
Oct 23, 2026190
Oct 22, 2026262
Oct 21, 2026328
Oct 20, 2026452
Oct 19, 2026438
Oct 18, 2026427
Oct 17, 2026514
Oct 16, 2026639
Oct 15, 2026658
Oct 14, 2026806
Oct 13, 2026727
Oct 12, 2026828
Oct 11, 20261,225
Oct 10, 20261,198
Oct 9, 20261,082
Oct 8, 20261,043
Oct 7, 2026855
Oct 6, 2026744
Oct 5, 2026607
Oct 4, 2026215
Oct 3, 2026154
Oct 2, 2026150
Oct 1, 2026114
Sep 30, 202698
Sep 29, 2026112
Sep 28, 2026119
Sep 27, 2026231
Sep 26, 2026255
Sep 25, 2026268
Sep 24, 2026292
Sep 23, 2026320
Sep 22, 2026327
Sep 21, 2026402
Sep 20, 2026309
Sep 19, 2026363
Sep 18, 2026458
Sep 17, 2026559
Sep 16, 2026613
Sep 15, 2026592
Sep 14, 2026514
Sep 13, 2026526
Sep 12, 2026497
Sep 11, 2026466
Sep 10, 2026365
Sep 9, 2026311
Sep 8, 2026304
Sep 7, 2026396

Each point is npm's rolling 7-day download count.

Health Score

85/100Excellent

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1066776166-root.svg)](https://payloaddirectory.dev/plugins/1066776166-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1066776166-root"><img src="https://payloaddirectory.dev/badge/1066776166-root.svg" alt="Payload Directory"></a>
Updated Dec 5, 2026Created Sep 30, 2025Published Dec 1, 2026

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.

OptionDefaultDescription
settings.autoSynctrueEnables startup and document lifecycle synchronisation.
settings.cacheSee belowSearch page cache capacity and TTL in milliseconds.
settings.reconcilefalsePrune stale indexed documents during startup synchronisation.
settings.batchSize100Number of documents processed per import batch.
settings.searchEndpoint/searchBase path for registered search endpoints, relative to Payload's API path.
settings.searchModekeywordDefault search mode. Supports keyword, semantic and hybrid search.
collections.*.syncLimit1000Number 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.

MethodEndpointPurpose
GET/api/searchSearch across collections
GET/api/search/{collection}Search a collection
POST/api/search/{collection}Advanced search
GET/api/search/{collection}/suggestSearch suggestions
GET/api/search/collectionsAvailable collections
GET/api/search/healthHealth status
GET/api/search/health/detailedDetailed 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 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support or inquiries:

Author

Rubix Studios
https://rubixstudios.com.au

Similar plugins