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 🙏

© 2025 – Pkg Stats / Ryan Hefner

typesense-search-plugin

v1.5.1

Published

A powerful, production-ready search plugin that integrates Typesense with Payload CMS, providing lightning-fast, typo-tolerant search capabilities with real-time synchronization and a comprehensive theme system.

Readme

Typesense Search Plugin for Payload CMS

A powerful, production-ready search plugin that integrates Typesense with Payload CMS, providing lightning-fast, typo-tolerant search capabilities with real-time synchronization.

📋 Prerequisites

  • Node.js: 22.19.0+ or 20.9.0+
  • Payload CMS: 3.64.0+
  • Typesense: 0.25.2+
  • pnpm (recommended) or npm/yarn

🚀 Quick Start

# 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)
      }}
    />
  )
}

✨ Features

  • ⚡ 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

📚 Documentation

For detailed documentation, visit our comprehensive docs:

🔧 API Endpoints

  • GET /api/search - Universal search across all collections
  • GET /api/search/{collection} - Search specific collection
  • POST /api/search/{collection} - Advanced search with filters
  • GET /api/search/{collection}/suggest - Search suggestions
  • GET /api/search/collections - Collection metadata
  • GET /api/search/health - Health check

🎨 Components

  • 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

🎨 Theme System

The plugin includes a powerful theme system with 5 pre-built themes and unlimited customization:

Pre-built Themes

// 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" />

Custom Themes

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} />

Theme Features

  • 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

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments