Skip to content

Commit

Permalink
Merge branch 'main' into bump-meilisearch-v1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
curquiza authored Feb 13, 2025
2 parents ee26856 + 1064d09 commit c4a5054
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 217 deletions.
87 changes: 57 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
<p align="center">
<a href="https://www.npmjs.com/package/meilisearch"><img src="https://img.shields.io/npm/v/meilisearch.svg" alt="npm version"></a>
<a href="https://github.com/meilisearch/meilisearch-js/actions"><img src="https://github.com/meilisearch/meilisearch-js/workflows/Tests/badge.svg" alt="Tests"></a>
<a href="https://codecov.io/gh/meilisearch/meilisearch-js">
<img src="https://codecov.io/github/meilisearch/meilisearch-js/coverage.svg?branch=main" alt="Codecov">
</a>
<a href="https://codecov.io/gh/meilisearch/meilisearch-js"><img src="https://codecov.io/github/meilisearch/meilisearch-js/coverage.svg?branch=main" alt="Codecov"></a>
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="Prettier"></a>
<a href="https://github.com/meilisearch/meilisearch-js/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
<a href="https://ms-bors.herokuapp.com/repositories/10"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
Expand Down Expand Up @@ -49,15 +47,22 @@ For general information on how to use Meilisearch—such as our API reference, t

## 🔧 Installation

We recommend installing `meilisearch-js` in your project with your package manager of choice.
This package is published to [npm](https://www.npmjs.com/package/meilisearch).

Installing with `npm`:

```sh
npm install meilisearch
npm i meilisearch
```

`meilisearch-js` officially supports `node` versions 18 Maintenance, 20 Maintenance and 22 LTS.
> [!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.
Instead of using a package manager, you may also import the library directly into your [HTML via a CDN](#include-script-tag).
Other runtimes, like Deno and Bun, aren't tested, but if they do not work with
this package, please open an issue.

### Run Meilisearch <!-- omit in toc -->

Expand All @@ -69,48 +74,70 @@ Instead of using a package manager, you may also import the library directly int

After installing `meilisearch-js`, you must import it into your application. There are many ways of doing that depending on your development environment.

<details>
<summary><h4>⚠️ If any issues arise importing <code>meilisearch/token</code></h4></summary>

- [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)

</details>

> [!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 https://github.com/meilisearch/meilisearch-js/issues/1789
> - exports will stop being directly available on the global object (usually `window`) https://github.com/meilisearch/meilisearch-js/issues/1806
>
> - [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 <!-- omit in toc -->

Usage in an ES module environment:

```javascript
import { MeiliSearch } from 'meilisearch'
```js
import { MeiliSearch } from "meilisearch";

const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
```

#### `<script>` tag <!-- omit in toc -->

Usage in an HTML (or alike) file:
This package also contains a [UMD](https://stackoverflow.com/a/77284527) bundled
version, which in this case is meant to be used in a
[`script src`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#src)
tag:

```html
<script src='https://cdn.jsdelivr.net/npm/meilisearch@latest/dist/bundles/meilisearch.umd.js'></script>
<script src="https://www.unpkg.com/meilisearch/dist/umd/index.min.js"></script>
<script>
const client = new meilisearch.MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
const client = new meilisearch.MeiliSearch(/* ... */);
// ...
</script>
```

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 <!-- omit in toc -->

Usage in a back-end node.js or another environment supporting CommonJS modules:

```javascript
const { MeiliSearch } = require('meilisearch')
```js
const { MeiliSearch } = require("meilisearch");

const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
```

#### React Native <!-- omit in toc -->
Expand All @@ -122,12 +149,12 @@ To use `meilisearch-js` with React Native, you must also install [react-native-u
Usage in a Deno environment:

```js
import { MeiliSearch } from "https://esm.sh/meilisearch"
import { MeiliSearch } from "npm:meilisearch";

const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
host: "http://127.0.0.1:7700",
apiKey: "masterKey",
});
```

## 🚀 Getting started
Expand Down Expand Up @@ -339,7 +366,6 @@ index
controller.abort()
```


### Using Meilisearch behind a proxy <!-- omit in toc -->

#### Custom request config <!-- omit in toc -->
Expand Down Expand Up @@ -1157,6 +1183,7 @@ client.createDump(): Promise<EnqueuedTask>
```ts
client.createSnapshot(): Promise<EnqueuedTask>
```

---

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.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,23 @@
]
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@eslint/js": "^9.19.0",
"@types/eslint__js": "^8.42.3",
"@vitest/coverage-v8": "2.0.5",
"@types/node": "^22.10.1",
"eslint": "^9.16.0",
"@types/node": "^22.13.0",
"eslint": "^9.19.0",
"eslint-plugin-tsdoc": "^0.4.0",
"@vitest/eslint-plugin": "^1.1.23",
"eslint-config-prettier": "^9.1.0",
"typescript": "^5.7.2",
"@vitest/eslint-plugin": "^1.1.25",
"eslint-config-prettier": "^10.0.1",
"typescript": "^5.7.3",
"vite": "^6.0.9",
"@typescript-eslint/utils": "^8.19.0",
"@typescript-eslint/utils": "^8.22.0",
"globals": "^15.14.0",
"lint-staged": "15.3.0",
"lint-staged": "15.4.3",
"prettier": "^3.4.2",
"prettier-plugin-jsdoc": "^1.3.0",
"prettier-plugin-jsdoc": "^1.3.2",
"typedoc": "^0.27.6",
"typescript-eslint": "^8.19.0",
"typescript-eslint": "^8.22.0",
"vitest": "2.0.5"
},
"packageManager": "[email protected]"
Expand Down
Loading

0 comments on commit c4a5054

Please sign in to comment.