Building search into a web application means choosing between client-side and server-side approaches, and between writing everything yourself or using a library that handles the heavy lifting. These seven tools cover the range from simple fuzzy matching to full production search engines.
For the implementation patterns that work regardless of which tool you choose, including debounce, request cancellation, and relevance scoring, the 137Foundry guide on search-as-you-type covers the complete approach. 137Foundry integrates these libraries into production web applications where search is a core feature.
1. Fuse.js
Fuse.js is a lightweight, zero-dependency JavaScript library for fuzzy searching. It works entirely in the browser, which means no server round-trip and no backend configuration. You pass it an array of objects and a set of keys to search, and it returns ranked results with fuzzy matching that handles typos.
Fuse.js is the right choice when your dataset fits in memory (typically under 10,000 small objects), when you want instant results without server requests, and when the full dataset can be safely exposed to the client. It supports field weighting, exact match priority over fuzzy matches, and a configurable fuzzy threshold.
Use it for: site-wide content search, documentation search, product catalog search for small stores, command palette interfaces.
2. Lunr.js
Lunr.js is a full-text search library for JavaScript, designed to create search indexes that behave like Solr or Elasticsearch but run entirely in the browser. Unlike Fuse.js, Lunr pre-builds an inverted index from your dataset, which makes large-dataset search significantly faster at the cost of an upfront indexing step.
Lunr supports boosting (weighting specific fields), stop words, stemming, and wildcard searches. The index can be built server-side and serialized to JSON for faster client-side loading. It is a good step up from Fuse.js when the dataset is larger or when you need proper full-text ranking rather than fuzzy matching.
Use it for: documentation sites, offline-capable web apps, static site search, any use case where the dataset changes infrequently.
3. Typesense
Typesense is an open-source search engine you can self-host or use through Typesense Cloud. It offers sub-10ms search responses, typo tolerance, faceting, and a clean API. Unlike a general-purpose database with full-text search bolted on, Typesense is designed specifically for instant search.
Typesense has official JavaScript and Node.js clients, React and Vue integrations, and a well-documented instant search UI widget library. For teams that want search-engine performance without paying for a SaaS product, self-hosting Typesense on a small instance is a viable option.
Use it for: e-commerce search, SaaS application search, any product where search quality is a competitive feature.
4. Meilisearch
Meilisearch is another open-source, self-hostable search engine with instant search results, typo tolerance, and faceting. Its developer experience is particularly smooth: simple HTTP API, official SDKs for most languages, and a dashboard for exploring your search index. Meilisearch is designed to be easy to set up and run, which makes it a popular choice for development teams that want search-engine quality without extensive DevOps work.
Meilisearch has a cloud hosted offering for teams that prefer not to manage infrastructure.
Use it for: the same use cases as Typesense; the choice between the two usually comes down to API preference and deployment environment.
5. Algolia
Algolia is the industry-standard hosted search-as-a-service platform. It handles infrastructure, relevance tuning, and scale; you send it your data and query it through their API. Algolia's InstantSearch library provides pre-built UI components for search inputs, results, facets, and pagination that work with React, Vue, Angular, and vanilla JavaScript.
Algolia is not free at scale, but it has a generous free tier suitable for small projects. Its primary advantages over self-hosted options are zero infrastructure management, extremely fast global CDN-backed responses, and a mature relevance tuning UI.
Use it for: production applications where search quality and response time matter, teams without dedicated DevOps capacity, global applications that need low-latency search across regions.
6. FlexSearch
FlexSearch is a high-performance full-text search library for JavaScript that claims to be the fastest in-browser search library available. It uses a different indexing approach than Lunr.js, trading some of Lunr's feature richness for raw speed. It supports multiple scoring algorithms, field weighting, and incremental updates to the index.
FlexSearch is a strong option when you have a large client-side dataset and search response time is the primary concern. It supports both browser and Node.js environments.
Use it for: large client-side datasets where Fuse.js starts to feel slow, real-time search in rich JavaScript applications.
7. PostgreSQL Full-Text Search
PostgreSQL's built-in full-text search is not a separate library, but it is frequently overlooked as a serious search option. Using tsvector and tsquery, PostgreSQL supports ranked full-text search with stemming, phrase search, proximity search, and field weighting.
For applications already using PostgreSQL, adding full-text search indexes avoids the operational overhead of a separate search service. It scales to millions of records with proper indexing and handles most search use cases without dedicated search infrastructure.
The limitation is that PostgreSQL full-text search does not support typo tolerance out of the box (fuzzy matching requires the pg_trgm extension) and its ranking algorithm is not as sophisticated as Algolia or Typesense. For many applications, though, it is plenty.
Use it for: applications already on PostgreSQL where search needs are moderate, teams that prefer fewer infrastructure components, internal tools and admin interfaces.
Choosing Between Them
The decision usually breaks down along two dimensions: whether the data can be loaded client-side or needs to stay on the server, and whether the team can manage a separate search infrastructure.
| Need | Library |
|---|---|
| Client-side, small dataset, zero config | Fuse.js |
| Client-side, larger dataset, full-text ranking | Lunr.js or FlexSearch |
| Server-side, self-hosted, free | Typesense or Meilisearch |
| Server-side, hosted service | Algolia |
| Server-side, existing PostgreSQL | pg full-text + pg_trgm |
Questions to Ask Before Choosing
Before committing to a library, three questions narrow the options quickly.
Can the full dataset be safely exposed to the client? Client-side libraries (Fuse.js, Lunr.js, FlexSearch) load the dataset into the browser. If the data contains prices, user records, unpublished content, or anything that should not be visible to all end users, client-side search is not appropriate regardless of performance benefits.
How often does the dataset change? Fuse.js re-indexes on each page load, which works when data changes infrequently. If records are added, updated, or deleted constantly, a server-side index with real-time update hooks handles freshness more reliably than reloading a static JSON file.
What level of relevance quality is required? For internal tools and admin interfaces, basic keyword matching is usually sufficient. For customer-facing product search, features like typo tolerance, field weighting, and faceting make a visible difference in how often users find what they are looking for on the first query.
What is the team's operational capacity? Algolia requires no infrastructure management but costs money at scale. Typesense and Meilisearch require a server but are free and self-hosted. PostgreSQL full-text requires no additional infrastructure if you are already running PostgreSQL.
The front-end implementation patterns (debounce, AbortController, loading states) apply regardless of which backend you use. The guide on building search-as-you-type covers those patterns in detail. 137Foundry has integrated Algolia, Typesense, and PostgreSQL full-text search into client projects across different scale requirements.
Top comments (0)