# @docsearch/js

> JavaScript package for DocSearch, the best search experience for docs.

Latest version **5.1.0** (published 2026-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @docsearch/js
pnpm add @docsearch/js
yarn add @docsearch/js
bun add @docsearch/js
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2026-09-09 |
| First published | 2020-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4380 |
| Author | Algolia, Inc. |
| Maintainers | shortcuts, lorrissaintgenez, 8bittitan, nyagudayev, dylantientcheu |

## Links

- npm: https://www.npmjs.com/package/@docsearch/js
- Repository: https://github.com/algolia/docsearch
- Homepage: https://docsearch.algolia.com
- Issues: https://github.com/algolia/docsearch/issues
- npm.io page: https://npm.io/package/@docsearch/js

## Recent versions

- 5.1.0 (latest) — 2026-09-09
- 5.0.0-beta.4 (beta) — 2026-08-06
- 3.0.0-alpha.50 (alpha) — 2022-02-03
- 5.0.5 — 2026-09-03
- 5.0.4 — 2026-08-24
- 5.0.3 — 2026-08-19
- 5.0.2 — 2026-08-17
- 5.0.1 — 2026-08-11
- 5.0.0 — 2026-08-06
- 5.0.0-beta.3 — 2026-08-06
- 5.0.0-beta.2 — 2026-08-04
- 5.0.0-beta.1 — 2026-07-28
- 4.7.0 — 2026-07-28
- 5.0.0-beta.0 — 2026-07-17
- 4.6.3 — 2026-04-27
- … 75 more at https://npm.io/package/@docsearch/js/versions

## README

# @docsearch/js

JavaScript package for [DocSearch](http://docsearch.algolia.com/), the best search experience for docs.

## Installation

```sh
npm install @docsearch/js@5
```

## Get started

If you don’t want to use a package manager, you can use a standalone endpoint:

```html
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@5"></script>
```

To get started, you need a [`container`](https://docsearch.algolia.com/docs/api#container) for your DocSearch component to go in. If you don’t have one already, you can insert one into your markup:

```html
<div id="docsearch"></div>
```

Then, insert DocSearch into it by calling the [`docsearch`](https://docsearch.algolia.com/docs/api) function and providing the container. It can be a [CSS selector](https://developer.mozilla.org/en-us/docs/web/css/css_selectors) or an [Element](https://developer.mozilla.org/en-us/docs/web/api/htmlelement).

Make sure to provide a [`container`](https://docsearch.algolia.com/docs/api#container) (for example, a `div`), not an `input`. DocSearch generates a fully accessible search box for you.

```js app.js
import docsearch from '@docsearch/js';

import '@docsearch/css';

docsearch({
  container: '#docsearch',
  appId: 'YOUR_APP_ID',
  indices: ['YOUR_INDEX_NAME'],
  apiKey: 'YOUR_SEARCH_API_KEY',
});
```

The default entry includes keyword search and Ask AI. Configure `askAi` or call `openAskAi()` on the returned instance when using Ask AI.

## Keyword-only entry

Use the `docsearch` subpath when your integration only needs keyword search. This entry excludes Ask AI code.

```js app.js
import docsearch from '@docsearch/js/docsearch';

import '@docsearch/css';

docsearch({
  container: '#docsearch',
  appId: 'YOUR_APP_ID',
  indices: ['YOUR_INDEX_NAME'],
  apiKey: 'YOUR_SEARCH_API_KEY',
});
```

For a standalone keyword-only script, load the explicit UMD file:

```html
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@5/dist/umd/docsearch.js"></script>
<script>
  window.docsearch({
    container: '#docsearch',
    appId: 'YOUR_APP_ID',
    indices: ['YOUR_INDEX_NAME'],
    apiKey: 'YOUR_SEARCH_API_KEY',
  });
</script>
```

Both UMD entries expose callable `window.docsearch`. Load only one of them: the package default loads the AI-capable `dist/umd/index.js`, while `dist/umd/docsearch.js` is keyword-only.

## Documentation

[Read documentation →](https://docsearch.algolia.com/docs/packages/js/getting-started)

---
_Source: https://npm.io/package/@docsearch/js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
