# meilisearch-js
**Repository Path**: trusted-list/meilisearch-js
## Basic Information
- **Project Name**: meilisearch-js
- **Description**: JavaScript/TypeScript client for Meilisearch
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: https://www.meilisearch.com
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-03-18
- **Last Updated**: 2026-04-15
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
Meilisearch JavaScript
⚡ The Meilisearch API client written for JavaScript
**Meilisearch JavaScript** is the Meilisearch API client for JavaScript developers.
**Meilisearch** is an open-source search engine. [Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch)
## Table of Contents
- [📖 Documentation](#-documentation)
- [🔧 Installation](#-installation)
- [🚀 Getting started](#-getting-started)
- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
- [💡 Learn more](#-learn-more)
- [⚙️ Contributing](#️-contributing)
## 📖 Documentation
Consult the [Meilisearch Documentation](https://www.meilisearch.com/docs/?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) for guides, tutorials, and API reference materials on using Meilisearch.
For detailed information about the `meilisearch-js` package, visit the [client library documentation](https://meilisearch.github.io/meilisearch-js/modules.html?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js).
## 🔧 Installation
This package is published to [npm](https://www.npmjs.com/package/meilisearch).
Installing with `npm`:
```sh
npm i meilisearch
```
> [!NOTE]
>
> Node.js
> [LTS and Maintenance versions](https://github.com/nodejs/Release?tab=readme-ov-file#release-schedule)
> are supported and tested. Other versions may or may not work.
Other runtimes, like Deno and Bun, aren't tested, but if they do not work with
this package, please open an issue.
### Run Meilisearch
⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js).
🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) our fast, open-source search engine on your own infrastructure.
### Import
After installing `meilisearch-js`, you must import it into your application. There are many ways of doing that depending on your development environment.
⚠️ If any issues arise importing meilisearch/token
- [TypeScript >= 4.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html)
is required
- [`tsconfig.json` has to be set up correctly](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports)
- take a look at
[Centralized Recommendations for TSConfig bases](https://github.com/tsconfig/bases?tab=readme-ov-file)
> [!WARNING]
>
> - [default export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#using_the_default_export)
> is deprecated and will be removed in a future version |
> [Issue](https://github.com/meilisearch/meilisearch-js/issues/1789)
> - regarding usage of package's UMD version via `script src`, exports will stop
> being directly available on the
> [global object](https://developer.mozilla.org/en-US/docs/Glossary/Global_object)
> | [Issue](https://github.com/meilisearch/meilisearch-js/issues/1806)
#### `import` syntax
Usage in an ES module environment:
```js
import { Meilisearch } from "meilisearch";
const client = new Meilisearch({
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
```
#### `
```
But keep in mind that each CDN ([JSDELIVR](https://www.jsdelivr.com),
[ESM.SH](https://esm.sh/), etc.) provide more ways to import packages, make sure
to read their documentation.
#### `require` syntax
Usage in a back-end node.js or another environment supporting CommonJS modules:
```js
const { Meilisearch } = require("meilisearch");
const client = new Meilisearch({
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
```
#### React Native
To use `meilisearch-js` with React Native, you must also install [react-native-url-polyfill](https://www.npmjs.com/package/react-native-url-polyfill).
#### Deno
Usage in a Deno environment:
```js
import { Meilisearch } from "npm:meilisearch";
const client = new Meilisearch({
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
```
## 🚀 Getting started
Take a look at the [playground](./playgrounds/javascript/src/meilisearch.ts) for a concrete example.
### Add documents
```js
const { Meilisearch } = require("meilisearch");
// Or if you are in a ES environment
import { Meilisearch } from "meilisearch";
(async () => {
const client = new Meilisearch({
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
// An index is where the documents are stored.
const index = client.index("movies");
const documents = [
{ id: 1, title: "Carol", genres: ["Romance", "Drama"] },
{ id: 2, title: "Wonder Woman", genres: ["Action", "Adventure"] },
{ id: 3, title: "Life of Pi", genres: ["Adventure", "Drama"] },
{
id: 4,
title: "Mad Max: Fury Road",
genres: ["Adventure", "Science Fiction"],
},
{ id: 5, title: "Moana", genres: ["Fantasy", "Action"] },
{ id: 6, title: "Philadelphia", genres: ["Drama"] },
];
// If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
let response = await index.addDocuments(documents);
console.log(response); // => { "uid": 0 }
})();
```
Tasks such as document addition always return a unique identifier. You can use this identifier `taskUid` to check the status (`enqueued`, `canceled`, `processing`, `succeeded` or `failed`) of a [task](https://www.meilisearch.com/docs/reference/api/tasks).
### Basic search
```javascript
// Meilisearch is typo-tolerant:
const search = await index.search("philoudelphia");
console.log(search);
```
Output:
```json
{
"hits": [
{
"id": "6",
"title": "Philadelphia",
"genres": ["Drama"]
}
],
"offset": 0,
"limit": 20,
"estimatedTotalHits": 1,
"processingTimeMs": 1,
"query": "philoudelphia"
}
```
### Using search parameters
`meilisearch-js` supports all [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters) described in our main documentation website.
```javascript
await index.search("wonder", {
attributesToHighlight: ["*"],
});
```
```json
{
"hits": [
{
"id": 2,
"title": "Wonder Woman",
"genres": ["Action", "Adventure"],
"_formatted": {
"id": "2",
"title": "Wonder Woman",
"genres": ["Action", "Adventure"]
}
}
],
"offset": 0,
"limit": 20,
"estimatedTotalHits": 1,
"processingTimeMs": 0,
"query": "wonder"
}
```
### Custom search with filters
To enable filtering, you must first add your attributes to the [`filterableAttributes` index setting](https://www.meilisearch.com/docs/reference/api/settings#filterable-attributes).
```js
await index.updateFilterableAttributes(["id", "genres"]);
```
You only need to perform this operation once per index.
Note that Meilisearch rebuilds your index whenever you update `filterableAttributes`. Depending on the size of your dataset, this might take considerable time. You can track the process using the [tasks API](https://www.meilisearch.com/docs/reference/api/tasks)).
After you configured `filterableAttributes`, you can use the [`filter` search parameter](https://www.meilisearch.com/docs/reference/api/search#filter) to refine your search:
```js
await index.search("wonder", {
filter: ["id > 1 AND genres = Action"],
});
```
```json
{
"hits": [
{
"id": 2,
"title": "Wonder Woman",
"genres": ["Action", "Adventure"]
}
],
"offset": 0,
"limit": 20,
"estimatedTotalHits": 1,
"processingTimeMs": 0,
"query": "wonder"
}
```
### Placeholder search
Placeholder search makes it possible to receive hits based on your parameters without having any query (`q`). For example, in a movies database you can run an empty query to receive all results filtered by `genre`.
```javascript
await index.search("", {
filter: ["genres = fantasy"],
facets: ["genres"],
});
```
```json
{
"hits": [
{
"id": 2,
"title": "Wonder Woman",
"genres": ["Action", "Adventure"]
},
{
"id": 5,
"title": "Moana",
"genres": ["Fantasy", "Action"]
}
],
"offset": 0,
"limit": 20,
"estimatedTotalHits": 2,
"processingTimeMs": 0,
"query": "",
"facetDistribution": {
"genres": {
"Action": 2,
"Fantasy": 1,
"Adventure": 1
}
}
}
```
Note that to enable faceted search on your dataset you need to add `genres` to the `filterableAttributes` index setting. For more information on filtering and faceting, [consult our documentation settings](https://www.meilisearch.com/docs/learn/fine_tuning_results/faceted_search).
#### Abortable search
You can abort a pending search request by providing an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to the request.
```js
const controller = new AbortController();
index
.search(
"wonder",
{},
{
signal: controller.signal,
},
)
.then((response) => {
/** ... */
})
.catch((e) => {
/** Catch AbortError here. */
});
controller.abort();
```
### Using Meilisearch behind a proxy
#### Custom request config
You can provide a custom request configuration. for example, with custom headers.
```ts
const client: Meilisearch = new Meilisearch({
host: "http://localhost:3000/api/meilisearch/proxy",
requestConfig: {
headers: {
Authorization: AUTH_TOKEN,
},
// OR
credentials: "include",
},
});
```
#### Custom http client
You can use your own HTTP client, for example, with [`axios`](https://github.com/axios/axios).
```ts
const client: Meilisearch = new Meilisearch({
host: "http://localhost:3000/api/meilisearch/proxy",
httpClient: async (url, opts) => {
const response = await $axios.request({
url,
data: opts?.body,
headers: opts?.headers,
method: (opts?.method?.toLocaleUpperCase() as Method) ?? "GET",
});
return response.data;
},
});
```
## 🤖 Compatibility with Meilisearch
This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.
## 💡 Learn more
The following sections in our main documentation website may interest you:
- **Managing documents**: see the [API reference](https://www.meilisearch.com/docs/reference/api/documents?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) or read more about [documents](https://www.meilisearch.com/docs/learn/core_concepts/documents).
- **Searching**: see the [API reference](https://www.meilisearch.com/docs/reference/api/search?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) or follow our guide on [search parameters](https://www.meilisearch.com/docs/reference/api/search?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js#search-parameters).
- **Managing indexes**: see the [API reference](https://www.meilisearch.com/docs/reference/api/indexes?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) or read more about [indexes](https://www.meilisearch.com/docs/learn/core_concepts/indexes?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js).
- **Configuring indexes**: see the [API reference](https://www.meilisearch.com/docs/reference/api/settings?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js) or follow our guide on [settings parameters](https://www.meilisearch.com/docs/reference/api/settings?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-js#settings_parameters).
Check out the [playgrounds](./playgrounds/) for examples of implementation.
## ⚙️ Contributing
We welcome all contributions, big and small! If you want to know more about this SDK's development workflow or want to contribute to the repo, please visit our [contributing guidelines](/CONTRIBUTING.md) for detailed instructions.
---
Meilisearch provides and maintains many SDKs and integration tools like this one. We want to provide everyone with an **amazing search experience for any kind of project**. For a full overview of everything we create and maintain, take a look at the [integration-guides](https://github.com/meilisearch/integration-guides) repository.