
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
react-minisearch-alpha
Advanced tools
React integration for the MiniSearch client side full-text search library.
First, make sure you have a compatible version of React and of MiniSearch installed.
Then, install via NPM or Yarn:
# With NPM:
npm install react-minisearch
# Or with Yarn:
yarn add react-minisearch
There are three main ways to use react-minisearch: the useMiniSearch hook, the withMiniSearch higher-order component, or the WithMiniSearch wrapper component.
import { useMiniSearch } from 'react-minisearch'
// Documents to search amongst
const documents = [
{ id: 1, name: 'Agata' },
{ id: 2, name: 'Finn' },
// …etc
]
// See MiniSearch for documentation on options
const miniSearchOptions = { fields: ['name'] }
const MyComponent = () => {
const { search, searchResults } = useMiniSearch(documents, miniSearchOptions)
const handleSearchChange = (event) => {
search(event.target.value)
}
return (
<div>
<input type='text' onChange={handleSearchChange} placeholder='Search…' />
<ol>
<h3>Results:</h3>
{
searchResults && searchResults.map((result, i) => {
return <li key={i}>{ result.name }</li>
})
}
</ol>
</div>
)
}
import { withMiniSearch } from 'react-minisearch'
const MyComponent = ({ search, searchResults }) => {
const handleSearchChange = (event) => {
search(event.target.value)
}
return (
<div>
<input type='text' onChange={handleSearchChange} placeholder='Search…' />
<ol>
<h3>Results:</h3>
{
searchResults && searchResults.map((result, i) => {
return <li key={i}>{ result.name }</li>
})
}
</ol>
</div>
)
}
// Documents to search amongst
const documents = [
{ id: 1, name: 'Agata' },
{ id: 2, name: 'Finn' },
// …etc
]
// See MiniSearch for documentation on options
const miniSearchOptions = { fields: ['name'] }
const MyComponentWithSearch = withSearch(documents, miniSearchOptions, MyComponent)
import { WithMiniSearch } from 'react-minisearch'
// Documents to search amongst
const documents = [
{ id: 1, name: 'Agata' },
{ id: 2, name: 'Finn' },
// …etc
]
// See MiniSearch for documentation on options
const miniSearchOptions = { fields: ['name'] }
const MyComponent = () => (
<WithMiniSearch documents={documents} options={miniSearchOptions}>
{
({ search, searchResults }) => {
const handleSearchChange = (event) => {
search(event.target.value)
}
return (
<div>
<input type='text' onChange={handleSearchChange} placeholder='Search…' />
<ol>
<h3>Results:</h3>
{
searchResults && searchResults.map((result, i) => {
return <li key={i}>{ result.name }</li>
})
}
</ol>
</div>
)
}
}
</WithMiniSearch>
)
The complete set of props that are provided by react-minisearch is the same
for all three ways (useMiniSearch, withMiniSearch, or WithMiniSearch):
search(query: string, searchOptions?: SearchOptions) => void: function to
be called in order to perform the search
searchResults: T[] | null: array of search results, or null when no
search was performed or search was cleared
rawResults: SearchResult[] | null: array of raw search results from
MiniSearch, including scores and match information, or null when no search
was performed or search was cleared
clearSearch() => void: function to be called in order to clear the search
(setting searchResults to null)
autoSuggest(query: string, searchOptions?: SearchOptions) => void:
function to be called in order to obtain auto suggestions
suggestions: Suggestion[] | null: array of auto suggestions, or null
when auto suggestions are not used or cleared
clearSuggestions() => void: function to be called in order to clear the
suggestions (setting suggestions to null)
add(document: T) => void: function to add a new document to the index
addAll(documents: T[]) => void: function to add several new documents to
the index in bulk
addAllAsync(documents: T[], options?: object) => Promise<void>: same as
addAll, but works asynchronously and in batches to avoid blocking the UI
remove(document: T) => void: function to remove a document from the index
removeById(id: any) => void: function to remove a document from the index
by its id
removeAll(documents?: T[]) => void: function to remove several documents,
or all documents, from the index
isIndexing: boolean: set to true when indexing via addAllAsync is in
progress, false otherwise
miniSearch: MiniSearch: the MiniSearch instance, for the (rare) cases
when it is necessary to use it directly
In this list, the type T is a generic type that refers to the type of the document being indexed.
Many of these props correspond to methods on the MiniSearch class, as
documented in the MiniSearch
library.
Check out the examples directory for a complete usage example. To run the
example app locally:
cd to the examples directoryyarn install (or npm install)yarn start (or npm run start)FAQs
React integration for MiniSearch
We found that react-minisearch-alpha demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.