Features
- Real-time search with debounced input
- Lemma, root, and fuzzy search options
- Highlighted search results by match type
- Pagination controls
- Match statistics and scoring
- TypeScript support
Setup
1
Install dependencies
2
Run the development server
From the workspace root:Or from the example directory:
3
Open your browser
Navigate to
http://localhost:5173Project structure
Loading data
Load all required datasets on app initialization:App.tsx
All data loaders return Promises and can be loaded in parallel using
Promise.all() for optimal performance.Search implementation
Implement debounced search with configurable options:App.tsx
Debounce hook
The custom debounce hook delays state updates:useDebounce.ts
Highlighting results
Render verses with highlighted matches usinggetHighlightRanges:
VerseItem.tsx
The
getHighlightRanges function returns UI-agnostic highlight ranges. You control how to render them in your component, avoiding dangerouslySetInnerHTML.Pagination
Implement pagination controls:App.tsx
Display search statistics
Show match counts by type:App.tsx
Dependencies
The example uses these key dependencies:package.json
Key features demonstrated
- Type safety: Full TypeScript support with proper types for all API calls
- Performance: Debounced search input and paginated results
- User experience: Loading states, search options, and visual feedback
- Highlighting: Match-type-specific highlighting using the
getHighlightRangesutility - Extensibility: Clean component structure for easy customization