Installation

Install LumoSearch in your project using npm, yarn, or pnpm.

Package Managers

npm

npm install @lumosearch/search

yarn

yarn add @lumosearch/search

pnpm

pnpm add @lumosearch/search

Requirements

  • Node.js 16+ or any modern browser
  • ES Modules support
  • TypeScript 4.5+ (optional, but recommended)

Import Styles

ESM (Recommended)

import { LumoSearch } from '@lumosearch/search'

CommonJS

const { LumoSearch } = require('@lumosearch/search')

Package Exports

LumoSearch provides multiple entry points:

@lumosearch/search

Main entry point with LumoSearch class, types, and persistence adapters

import {
  LumoSearch,
  InMemoryStorage,
  IndexedDbStorage
} from '@lumosearch/search'

@lumosearch/search/worker

Web Worker wrapper for off-main-thread search

import { LumoSearchWorker } from '@lumosearch/search/worker'

@lumosearch/search/worker-script

Raw worker script entry for custom bundler setups

// Used internally, rarely needed directly

TypeScript Setup

LumoSearch includes TypeScript definitions out of the box:

import { LumoSearch, SearchResult, LumoSearchOptions } from '@lumosearch/search'

interface Document {
  id: number
  title: string
  body: string
}

const docs: Document[] = [
  { id: 1, title: 'First', body: 'Content' }
]

const options: LumoSearchOptions = {
  keys: [{ name: 'title', weight: 3 }]
}

const search = new LumoSearch<Document>(docs, options)
const results: SearchResult<Document>[] = search.search('query')

CDN Usage

For quick prototyping, you can use a CDN:

<script type="module">
  import { LumoSearch } from 'https://esm.sh/@lumosearch/search'

  const search = new LumoSearch(docs, {
    keys: ['title']
  })

  const results = search.search('query')
  console.log(results)
</script>

Not recommended for production: Use a package manager and bundler for production builds to ensure optimal bundle size and caching.

Bundler Configuration

Vite

// vite.config.js
export default {
  optimizeDeps: {
    include: ['@lumosearch/search']
  }
}

Webpack

// webpack.config.js
module.exports = {
  resolve: {
    extensions: ['.js', '.ts']
  }
}

Next.js

// next.config.js
module.exports = {
  transpilePackages: ['@lumosearch/search']
}

Browser Compatibility

LumoSearch works in all modern browsers:

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+
  • Mobile browsers (iOS Safari 14+, Chrome Android)

Verify Installation

// test.js
import { LumoSearch } from '@lumosearch/search'

const docs = [
  { title: 'Test Document' }
]

const search = new LumoSearch(docs, {
  keys: ['title']
})

const results = search.search('test')
console.log('✅ LumoSearch installed successfully!')
console.log('Results:', results.length)
node test.js

Next Steps