Gathering detailed insights and metrics for @sublet/typesense-instantsearch-adapter
Gathering detailed insights and metrics for @sublet/typesense-instantsearch-adapter
Gathering detailed insights and metrics for @sublet/typesense-instantsearch-adapter
Gathering detailed insights and metrics for @sublet/typesense-instantsearch-adapter
A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
npm install @sublet/typesense-instantsearch-adapter
Typescript
Module System
Node Version
NPM Version
JavaScript (90.62%)
HTML (6.54%)
TypeScript (1.9%)
CSS (0.93%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
473 Stars
521 Commits
72 Forks
13 Watchers
8 Branches
12 Contributors
Updated on Jul 17, 2025
Latest Version
2.3.0-0
Package Id
@sublet/typesense-instantsearch-adapter@2.3.0-0
Unpacked Size
510.41 kB
Size
121.38 kB
File Count
19
NPM Version
6.14.8
Node Version
12.19.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
26
An adapter to use the awesome Instantsearch.js library with a Typesense Search Server, to build rich search interfaces.
Here is an example of UI you can build with this adapater: songs-search.typesense.org
The good folks over at Algolia have built and open-sourced Instantsearch.js which is a collection of out-of-the-box components that you can use to build interactive search experiences swiftly.
With the adapter in this repository, you'll be able to use Instantsearch (and its React, Vue and Angular cousins) with data indexed in a Typesense search server.
If you haven't used Instantsearch before, we recommend going through their Getting Started guide here. Once you go through the guide, follow the instructions below to plug the Typesense adapter into Instantsearch.
Here's a guide on building a quick search interface with Typesense and InstantSearch.js: https://typesense.org/docs/0.20.0/guide/search-ui-components.html
Here's a demo starter app that shows you how to use the adapter: https://github.com/typesense/typesense-instantsearch-demo
1$ npm install --save typesense-instantsearch-adapter @babel/runtime
or
1$ yarn add typesense-instantsearch-adapter @babel/runtime
or, you can also directly include the adapter via a script tag in your HTML:
1<script src="https://cdn.jsdelivr.net/npm/typesense-instantsearch-adapter@2/dist/typesense-instantsearch-adapter.min.js"></script> 2 3<!-- You might want to pin the version of the adapter used if you don't want to always receive the latest minor version -->
Since this is an adapter, it will not install the Instantsearch library automatically for you. You need to install one of the following in your application directly:
You'll find information on how to get started with each of the above libraries in their respective repos.
We'd also recommend checking out create-instantsearch-app to create your Search UI from a starter template.
1import instantsearch from "instantsearch.js"; 2import { searchBox, hits } from "instantsearch.js/es/widgets"; 3import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter"; 4 5const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({ 6 server: { 7 apiKey: "abcd", // Be sure to use an API key that only allows search operations 8 nodes: [ 9 { 10 host: "localhost", 11 port: "8108", 12 protocol: "http", 13 }, 14 ], 15 }, 16 cacheSearchResultsForSeconds: 2 * 60, // Cache search results from server. Defaults to 2 minutes. Set to 0 to disable caching. 17 // The following parameters are directly passed to Typesense's search API endpoint. 18 // So you can pass any parameters supported by the search endpoint below. 19 // queryBy is required. 20 additionalSearchParameters: { 21 queryBy: "name,description,categories", 22 }, 23}); 24const searchClient = typesenseInstantsearchAdapter.searchClient; 25 26const search = instantsearch({ 27 searchClient, 28 indexName: "products", 29}); 30search.addWidgets([ 31 searchBox({ 32 container: "#searchbox", 33 }), 34 hits({ 35 container: "#hits", 36 templates: { 37 item: ` 38 <div class="hit-name"> 39 {{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}} 40 </div> 41 `, 42 }, 43 }), 44]); 45 46search.start();
You can add any of the Instantsearch widgets here that are supported by the adapter.
You'll also find a working example in test/support/testground. To run it, run npm run testground
from the project root folder.
1import React from "react";
2import ReactDOM from "react-dom";
3import { SearchBox } from "react-instantsearch-dom";
4import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";
5
6const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
7 server: {
8 apiKey: "abcd", // Be sure to use an API key that only allows search operations
9 nodes: [
10 {
11 host: "localhost",
12 port: "8108",
13 protocol: "http",
14 },
15 ],
16 },
17 cacheSearchResultsForSeconds: 2 * 60, // Cache search results from server. Defaults to 2 minutes. Set to 0 to disable caching.
18 // The following parameters are directly passed to Typesense's search API endpoint.
19 // So you can pass any parameters supported by the search endpoint below.
20 // queryBy is required.
21 additionalSearchParameters: {
22 queryBy: "name,description,categories",
23 },
24});
25const searchClient = typesenseInstantsearchAdapter.searchClient;
26
27const App = () => (
28 <InstantSearch indexName="products" searchClient={searchClient}>
29 <SearchBox />
30 <Hits />
31 </InstantSearch>
32);
You can then add any of the Instantsearch-React widgets here that are supported by the adapter.
App.vue:
1<template>
2 <ais-instant-search :search-client="searchClient" index-name="products">
3 <ais-search-box />
4 <ais-hits>
5 <div slot="item" slot-scope="{ item }">
6 <h2>{{ item.name }}</h2>
7 </div>
8 </ais-hits>
9 </ais-instant-search>
10</template>
11
12<script>
13import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";
14
15const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
16 server: {
17 apiKey: "abcd", // Be sure to use an API key that only allows search operations
18 nodes: [
19 {
20 host: "localhost",
21 port: "8108",
22 protocol: "http",
23 },
24 ],
25 },
26 cacheSearchResultsForSeconds: 2 * 60, // Cache search results from server. Defaults to 2 minutes. Set to 0 to disable caching.
27 // The following parameters are directly passed to Typesense's search API endpoint.
28 // So you can pass any parameters supported by the search endpoint below.
29 // queryBy is required.
30 additionalSearchParameters: {
31 queryBy: "name,description,categories",
32 },
33});
34const searchClient = typesenseInstantsearchAdapter.searchClient;
35
36export default {
37 data() {
38 return {
39 searchClient,
40 };
41 },
42};
43</script>
You can then add any of the Instantsearch widgets here that are supported by the adapter.
1// app.component.ts 2import { Component } from "@angular/core"; 3import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter"; 4 5const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({ 6 server: { 7 apiKey: "abcd", // Be sure to use an API key that only allows search operations 8 nodes: [ 9 { 10 host: "localhost", 11 port: "8108", 12 protocol: "http", 13 }, 14 ], 15 }, 16 cacheSearchResultsForSeconds: 2 * 60, // Cache search results from server. Defaults to 2 minutes. Set to 0 to disable caching. 17 // The following parameters are directly passed to Typesense's search API endpoint. 18 // So you can pass any parameters supported by the search endpoint below. 19 // queryBy is required. 20 additionalSearchParameters: { 21 queryBy: "name,description,categories", 22 }, 23}); 24const searchClient = typesenseInstantsearchAdapter.searchClient; 25 26@Component({ 27 selector: "app-root", 28 templateUrl: "./app.component.html", 29 styleUrls: ["./app.component.css"], 30}) 31export class AppComponent { 32 config = { 33 indexName: "products", 34 searchClient, 35 }; 36}
You can then add any of the Instantsearch widgets here that are supported by the adapter.
hierarchicalMenu
For this widget, you want to create independent fields in the collection's schema with this specific naming convention:
field.lvl0
field.lvl1
field.lvl2
for a nested hierarchy of field.lvl0 > field.lvl1 > field.lvl2
Each of these fields can also hold an array of values. This is useful for handling multiple hierarchies.
sortBy
When instantiating this widget, you want to set the value of the index name to this particular format:
1search.addWidgets([ 2 sortBy({ 3 container: "#sort-by", 4 items: [ 5 { label: "Default", value: "products" }, 6 { label: "Price (asc)", value: "products/sort/price:asc" }, 7 { label: "Price (desc)", value: "products/sort/price:desc" }, 8 ], 9 }), 10]);
The generalized pattern for the value attribute is: <index_name>[/sort/<sort_by>]
. The adapter will use the value in <sort_by>
as the value for the sort_by
search parameter.
configure
If you need to specify a filter_by
search parameter for Typesense, you want to use the appropriate configure
InstantSearch widget. Setting filter_by
inside the additionalQueryParameters
config does not work, because InstantSearch internally overrides the filter_by
field. So you want to use InstantSearch to configure it. Read more here.
index
For Federated / Multi-Index Search, you'd need to use the index
widget. To then be able to specify different search parameters for each index/collection, you can specify them using the collectionSpecificSearchParameters
configuration:
1const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
2 server: {
3 apiKey: "abcd", // Be sure to use an API key that only allows search operations
4 nodes: [{ host: "localhost", port: "8108", protocol: "http" }],
5 },
6 // Search parameters that are common to all collections/indices go here:
7 additionalSearchParameters: {
8 numTypos: 3,
9 },
10 // Search parameters that need to be *overridden* on a per-collection-basis go here:
11 collectionSpecificSearchParameters: {
12 products: {
13 queryBy: "name,description,categories",
14 },
15 brands: {
16 queryBy: "name",
17 },
18 },
19});
20const searchClient = typesenseInstantsearchAdapter.searchClient;
Essentially, any parameters set in collectionSpecificSearchParameters
will be merged with the values in additionalSearchParameters
when querying Typesense, effectively overriding values in additionalSearchParameters
on a per-collection-basis.
geoSearch
Algolia uses _geoloc
by default for the name of the field that stores the lat long values for a record.
In Typesense, you can name the geo location field anything. If you use a name other than _geoloc
, you need to specify it when initializing the adapter like below, so InstantSearch can access it:
1const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({ 2 server: { 3 apiKey: "xyz", 4 nodes: [ 5 { 6 host: "localhost", 7 port: "8108", 8 protocol: "http", 9 }, 10 ], 11 }, 12 geoLocationField: "lat_lng_field", // <<====== 13 additionalSearchParameters, 14});
Typesense Server | typesense-instantsearch-adapter | instantsearch.js | react-instantsearch | vue-instantsearch | angular-instantsearch |
---|---|---|---|---|---|
>= v0.21 | >= v2.0.0 | >= 4.2.0 | >= 6.0.0 | >= 2.2.1 | >= 3.0.0 |
>= v0.19 | >= v1.0.0 | >= 4.2.0 | >= 6.0.0 | >= 2.2.1 | >= 3.0.0 |
>= v0.15 | >= v0.3.0 | >= 4.2.0 | >= 6.0.0 | >= 2.2.1 | >= 3.0.0 |
>= v0.14 | >= v0.2.0 | >= 4.2.0 | >= 6.0.0 | >= 2.2.1 | >= 3.0.0 |
>= v0.13 | >= v0.1.0 | >= 4.2.0 | >= 6.0.0 | >= 2.2.1 | >= 3.0.0 |
>= v0.12 | >= v0.0.4 | >= 4.2.0 | >= 6.0.0 | >= 2.2.1 | >= 3.0.0 |
If a particular version of the above libraries don't work with the adapter, please open a Github issue with details.
This adapter works with all widgets in this list, except for the following:
queryRuleCustomData
queryRuleContext
1$ npm install 2$ npm run typesenseServer 3$ FORCE_REINDEX=true npm run indexTestData 4 5$ npm link typesense-instantsearch-adapter 6$ npm run testground 7 8$ npm test
To release a new version, we use the np package:
1$ npm install --global np 2$ np 3 4# Follow instructions that np shows you 5
If you have any questions or run into any problems, please create a Github issue and we'll try our best to help.
© 2020-present Typesense, Inc.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
29 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/14 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
41 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More