diff --git a/README.md b/README.md index 1488ff7d8..69402d4c8 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,7 @@

npm version Tests - - Codecov - + Codecov Prettier License Bors enabled @@ -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 @@ -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. +

+

⚠️ 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 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 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", +}); ``` #### ` + ``` +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: -```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 @@ -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 @@ -339,7 +366,6 @@ index controller.abort() ``` - ### Using Meilisearch behind a proxy #### Custom request config @@ -1159,6 +1185,7 @@ client.createDump(): Promise ```ts client.createSnapshot(): Promise ``` + --- 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.