A powerful, production-ready search plugin that integrates Typesense with Payload CMS, providing lightning-fast, typo-tolerant search capabilities with real-time synchronization.
# 1. Install the plugin
pnpm add typesense-search-plugin
# 2. Start Typesense
docker run -p 8108:8108 -v/tmp/typesense-data:/data typesense/typesense:0.25.2 --data-dir /data --api-key=xyz --enable-cors
# 3. Add to your Payload config
// payload.config.ts
import { buildConfig } from 'payload/config'
import { typesenseSearch } from 'typesense-search-plugin'
export default buildConfig({
plugins: [
typesenseSearch({
typesense: {
apiKey: 'xyz',
nodes: [{ host: 'localhost', port: 8108, protocol: 'http' }],
},
collections: {
posts: {
enabled: true,
searchFields: ['title', 'content'],
facetFields: ['category', 'status'],
displayName: 'Blog Posts',
icon: 'π',
},
},
}),
],
})
// 4. Use the search component
import { HeadlessSearchInput } from 'typesense-search-plugin'
function SearchPage() {
return (
<HeadlessSearchInput
baseUrl="http://localhost:3000"
theme="modern" // Choose from: modern, minimal, elegant, dark, colorful
placeholder="Search everything..."
onResultClick={(result) => {
console.log('Selected:', result.document)
}}
/>
)
}
// Multi-collection search
function MultiCollectionSearch() {
return (
<HeadlessSearchInput
baseUrl="http://localhost:3000"
collections={['posts', 'products']}
placeholder="Search posts & products..."
onResultClick={(result) => {
console.log('Selected:', result.document)
}}
/>
)
}
// Single collection search
function PostSearch() {
return (
<HeadlessSearchInput
baseUrl="http://localhost:3000"
collection="posts"
placeholder="Search posts..."
onResultClick={(result) => {
console.log('Selected:', result.document)
}}
/>
)
}
- β‘ Lightning Fast: Sub-millisecond search response times
- π Flexible Search: Single, multiple, or universal collection search with one component
- π¨ Modern UI: Beautiful, responsive design with Tailwind CSS
- π― Smart API Selection: Automatically chooses optimal endpoint for performance
- π Real-time Sync: Automatic synchronization with Payload CMS
- πΎ Built-in Caching: In-memory cache with configurable TTL
- π‘οΈ Production Ready: Comprehensive error handling and performance optimization
- π± Responsive: Mobile-first design that works on all devices
For detailed documentation, visit our comprehensive docs:
- Getting Started
- Installation Guide
- Configuration
- API Reference
- Components
- Customization
- Performance
- Troubleshooting
GET /api/search
- Universal search across all collectionsGET /api/search/{collection}
- Search specific collectionPOST /api/search/{collection}
- Advanced search with filtersGET /api/search/{collection}/suggest
- Search suggestionsGET /api/search/collections
- Collection metadataGET /api/search/health
- Health check
HeadlessSearchInput
- Single component supporting all search patterns:- Single Collection:
collection="posts"
- Direct API calls for optimal performance - Multiple Collections:
collections={['posts', 'products']}
- Smart filtering with universal search - Universal Search: No collection props - Search across all collections
- Complete UI Control: Customizable rendering with comprehensive theme system
- Single Collection:
The plugin includes a powerful theme system with 5 pre-built themes and unlimited customization:
// Modern theme (default) - Clean and professional
<HeadlessSearchInput theme="modern" />
// Minimal theme - Flat design with minimal styling
<HeadlessSearchInput theme="minimal" />
// Elegant theme - Sophisticated with gradients
<HeadlessSearchInput theme="elegant" />
// Dark theme - Perfect for dark mode
<HeadlessSearchInput theme="dark" />
// Colorful theme - Vibrant and modern
<HeadlessSearchInput theme="colorful" />
const customTheme = {
theme: 'modern',
colors: {
inputBorderFocus: '#10b981',
inputBackground: '#f0fdf4',
resultsBackground: '#f0fdf4',
},
spacing: {
inputPadding: '1rem 1.25rem',
inputBorderRadius: '1.5rem',
},
enableAnimations: true,
enableShadows: true,
}
<HeadlessSearchInput theme={customTheme} />
- 5 Pre-built Themes: Modern, Minimal, Elegant, Dark, Colorful
- Unlimited Customization: Override any color, spacing, typography, or animation
- Performance Options: Disable animations/shadows for better performance
- Responsive Design: Automatic mobile optimization
- CSS Variables: Advanced styling with CSS custom properties
- TypeScript Support: Full type safety for all theme configurations
- π¨ Comprehensive Theme System: 5 pre-built themes (Modern, Minimal, Elegant, Dark, Colorful)
- π¨ Unlimited Customization: Override any color, spacing, typography, or animation
- π¨ Performance Options: Disable animations/shadows for better performance
- π¨ Responsive Design: Automatic mobile optimization with theme system
- π¨ CSS Variables: Advanced styling with CSS custom properties (29 variables)
- π¨ TypeScript Support: Full type safety for all theme configurations
- π¨ Theme Provider: Advanced theme context management
- π¨ React Hooks: useTheme, useThemeConfig, useResponsiveTheme for theme management
- π¨ Developer-Friendly: All theme configurations within the plugin and components
- π Enhanced HeadlessSearchInput: Now supports comprehensive theme system integration
- π― Smart API Selection: Automatically chooses the most efficient endpoint
- π Relative Scoring: Meaningful percentage display for search result relevance
- π§ Simplified Architecture: One component handles all search patterns
- π± Responsive Design: Mobile-first approach with excellent UX
- β‘ Performance: Optimized with client-side filtering and efficient API calls
- π Complete Documentation: Comprehensive theme system documentation with examples
- π§ͺ Integrated Demo: Theme showcase and testing interface in search demo
If you were using UnifiedSearchInput
, simply replace it with HeadlessSearchInput
:
// Before (v1.2.0)
import { UnifiedSearchInput } from 'typesense-search-plugin'
;<UnifiedSearchInput collections={['posts']} />
// After (v1.3.0)
import { HeadlessSearchInput } from 'typesense-search-plugin'
;<HeadlessSearchInput collection="posts" />
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details.
- Typesense for the amazing search engine
- Payload CMS for the flexible headless CMS