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.
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-typesense33
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
33+5 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 33 |
| Dec 5, 2026 | 33 |
| Dec 4, 2026 | 33 |
| Dec 3, 2026 | 33 |
| Dec 2, 2026 | 33 |
| Dec 1, 2026 | 33 |
| Nov 30, 2026 | 33 |
| Nov 29, 2026 | 33 |
| Nov 28, 2026 | 33 |
| Nov 27, 2026 | 33 |
| Nov 26, 2026 | 33 |
| Nov 25, 2026 | 33 |
| Nov 24, 2026 | 33 |
| Nov 23, 2026 | 33 |
| Nov 22, 2026 | 33 |
| Nov 21, 2026 | 33 |
| Nov 20, 2026 | 33 |
| Nov 19, 2026 | 33 |
| Nov 18, 2026 | 33 |
| Nov 17, 2026 | 33 |
| Nov 16, 2026 | 33 |
| Nov 15, 2026 | 33 |
| Nov 14, 2026 | 33 |
| Nov 13, 2026 | 33 |
| Nov 12, 2026 | 33 |
| Nov 11, 2026 | 33 |
| Nov 10, 2026 | 33 |
| Nov 9, 2026 | 33 |
| Nov 8, 2026 | 33 |
| Nov 7, 2026 | 33 |
| Nov 6, 2026 | 33 |
| Nov 5, 2026 | 33 |
| Nov 4, 2026 | 33 |
| Nov 3, 2026 | 33 |
| Nov 2, 2026 | 33 |
| Nov 1, 2026 | 32 |
| Oct 31, 2026 | 32 |
| Oct 30, 2026 | 32 |
| Oct 29, 2026 | 32 |
| Oct 28, 2026 | 32 |
| Oct 27, 2026 | 32 |
| Oct 26, 2026 | 32 |
| Oct 25, 2026 | 32 |
| Oct 24, 2026 | 32 |
| Oct 23, 2026 | 32 |
| Oct 22, 2026 | 32 |
| Oct 21, 2026 | 32 |
| Oct 20, 2026 | 32 |
| Oct 19, 2026 | 32 |
| Oct 18, 2026 | 32 |
| Oct 17, 2026 | 32 |
| Oct 16, 2026 | 32 |
| Oct 15, 2026 | 32 |
| Oct 14, 2026 | 32 |
| Oct 13, 2026 | 30 |
| Oct 12, 2026 | 30 |
| Oct 11, 2026 | 29 |
| Oct 10, 2026 | 29 |
| Oct 9, 2026 | 28 |
| Oct 8, 2026 | 28 |
| Oct 7, 2026 | 28 |
| Oct 6, 2026 | 28 |
| Oct 5, 2026 | 28 |
| Oct 4, 2026 | 28 |
| Oct 3, 2026 | 28 |
| Oct 2, 2026 | 28 |
| Oct 1, 2026 | 28 |
| Sep 30, 2026 | 28 |
| Sep 29, 2026 | 28 |
| Sep 28, 2026 | 28 |
| Sep 27, 2026 | 28 |
| Sep 26, 2026 | 28 |
| Sep 25, 2026 | 28 |
| Sep 24, 2026 | 28 |
| Sep 23, 2026 | 28 |
| Sep 22, 2026 | 28 |
| Sep 21, 2026 | 28 |
| Sep 20, 2026 | 28 |
| Sep 19, 2026 | 28 |
| Sep 18, 2026 | 28 |
| Sep 17, 2026 | 28 |
| Sep 16, 2026 | 28 |
| Sep 15, 2026 | 28 |
| Sep 14, 2026 | 28 |
| Sep 13, 2026 | 28 |
| Sep 12, 2026 | 28 |
| Sep 11, 2026 | 28 |
| Sep 10, 2026 | 28 |
| Sep 9, 2026 | 28 |
| Sep 8, 2026 | 28 |
| Sep 7, 2026 | 28 |
1.3K+943 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 1,339 |
| Dec 5, 2026 | 1,285 |
| Dec 4, 2026 | 1,538 |
| Dec 3, 2026 | 1,446 |
| Dec 2, 2026 | 1,193 |
| Dec 1, 2026 | 1,144 |
| Nov 30, 2026 | 1,348 |
| Nov 29, 2026 | 1,295 |
| Nov 28, 2026 | 1,281 |
| Nov 27, 2026 | 964 |
| Nov 26, 2026 | 758 |
| Nov 25, 2026 | 771 |
| Nov 24, 2026 | 796 |
| Nov 23, 2026 | 582 |
| Nov 22, 2026 | 586 |
| Nov 21, 2026 | 715 |
| Nov 20, 2026 | 848 |
| Nov 19, 2026 | 796 |
| Nov 18, 2026 | 828 |
| Nov 17, 2026 | 730 |
| Nov 16, 2026 | 728 |
| Nov 15, 2026 | 701 |
| Nov 14, 2026 | 556 |
| Nov 13, 2026 | 530 |
| Nov 12, 2026 | 604 |
| Nov 11, 2026 | 729 |
| Nov 10, 2026 | 788 |
| Nov 9, 2026 | 785 |
| Nov 8, 2026 | 778 |
| Nov 7, 2026 | 735 |
| Nov 6, 2026 | 577 |
| Nov 5, 2026 | 505 |
| Nov 4, 2026 | 304 |
| Nov 3, 2026 | 235 |
| Nov 2, 2026 | 219 |
| Nov 1, 2026 | 226 |
| Oct 31, 2026 | 238 |
| Oct 30, 2026 | 263 |
| Oct 29, 2026 | 230 |
| Oct 28, 2026 | 199 |
| Oct 27, 2026 | 254 |
| Oct 26, 2026 | 278 |
| Oct 25, 2026 | 255 |
| Oct 24, 2026 | 239 |
| Oct 23, 2026 | 190 |
| Oct 22, 2026 | 262 |
| Oct 21, 2026 | 328 |
| Oct 20, 2026 | 452 |
| Oct 19, 2026 | 438 |
| Oct 18, 2026 | 427 |
| Oct 17, 2026 | 514 |
| Oct 16, 2026 | 639 |
| Oct 15, 2026 | 658 |
| Oct 14, 2026 | 806 |
| Oct 13, 2026 | 727 |
| Oct 12, 2026 | 828 |
| Oct 11, 2026 | 1,225 |
| Oct 10, 2026 | 1,198 |
| Oct 9, 2026 | 1,082 |
| Oct 8, 2026 | 1,043 |
| Oct 7, 2026 | 855 |
| Oct 6, 2026 | 744 |
| Oct 5, 2026 | 607 |
| Oct 4, 2026 | 215 |
| Oct 3, 2026 | 154 |
| Oct 2, 2026 | 150 |
| Oct 1, 2026 | 114 |
| Sep 30, 2026 | 98 |
| Sep 29, 2026 | 112 |
| Sep 28, 2026 | 119 |
| Sep 27, 2026 | 231 |
| Sep 26, 2026 | 255 |
| Sep 25, 2026 | 268 |
| Sep 24, 2026 | 292 |
| Sep 23, 2026 | 320 |
| Sep 22, 2026 | 327 |
| Sep 21, 2026 | 402 |
| Sep 20, 2026 | 309 |
| Sep 19, 2026 | 363 |
| Sep 18, 2026 | 458 |
| Sep 17, 2026 | 559 |
| Sep 16, 2026 | 613 |
| Sep 15, 2026 | 592 |
| Sep 14, 2026 | 514 |
| Sep 13, 2026 | 526 |
| Sep 12, 2026 | 497 |
| Sep 11, 2026 | 466 |
| Sep 10, 2026 | 365 |
| Sep 9, 2026 | 311 |
| Sep 8, 2026 | 304 |
| Sep 7, 2026 | 396 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1066776166-root)<a href="https://payloaddirectory.dev/plugins/1066776166-root"><img src="https://payloaddirectory.dev/badge/1066776166-root.svg" alt="Payload Directory"></a>README
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.
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.
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.
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.
'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)
}}
/>
)
}
'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)
}}
/>
)
}
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.
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.
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.
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 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}.
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.
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.
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.
This project is licensed under the MIT License - see the LICENSE file for details.
For support or inquiries:
Rubix Studios
https://rubixstudios.com.au
Topics
search
Generate fast-to-query search records from your Payload documents
100128.3k/wk46.1kv3 v4
algolia search
Algolia search sync for Payload with draft-aware indexing, automatic text extraction and admin reindex buttons
5937/wk16v3
payload plugin algolia
Sync Payload collections to an Algolia search index
54124/wk17v3
payload related items
Related content suggestions using BM25 and Jaccard similarity, with an admin sidebar widget and REST endpoint
4045/wk3v3
payload upstash
Upstash Redis key-value adapter for Payload's built-in KV store
82333/wk7v3 v4
payload plugin cache refresh
Admin dashboard button that refreshes Next.js cache tags for permitted users, with confirmation and optional page…
78385/wk0v3