# chair-flight-docsearch-react

> A clone of Algolia's React DocSearch, but it accepts any search backend.

Latest version **3.0.4** (published 2022-04-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install chair-flight-docsearch-react
pnpm add chair-flight-docsearch-react
yarn add chair-flight-docsearch-react
bun add chair-flight-docsearch-react
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2022-04-23 |
| First published | 2022-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 359.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | pupoSDC |
| Maintainers | puposdc |

## Links

- npm: https://www.npmjs.com/package/chair-flight-docsearch-react
- Repository: https://github.com/chair-flight/chair-flight-docsearch-react
- npm.io page: https://npm.io/package/chair-flight-docsearch-react

## Dependencies (2)

- [@docsearch/css](https://npm.io/package/@docsearch/css.md) 3.0.0
- [@algolia/autocomplete-core](https://npm.io/package/@algolia/autocomplete-core.md) 1.6.2

## Recent versions

- 3.0.4 (latest) — 2022-04-23
- 3.0.3 — 2022-04-22
- 3.0.2 — 2022-04-22
- 3.0.1 — 2022-04-22
- 3.0.0 — 2022-04-22

## README

# chair-flight Docsearch React

A clone of Algolia's React [DocSearch](http://docsearch.algolia.com/), but it accepts any 
search backend.

## Installation

```bash
yarn add chair-flight-docsearch-react
# or
npm install chair-flight-docsearch-react
```

## Get started

The api for the component is pretty much the same as the original `docsearch-react`
except that instead of providing an `appId` and `apiKey` you are supposed to pass 
an arbitrary search function:

```tsx
import { DocSearch } from '@docsearch/react';

import '@docsearch/css';

function App() {
  return (
    <DocSearch
      search={async (queryString) => myCustomBackend.search(queryString).map(toDocSearchHit)}
      indexName="YOUR_INDEX_NAME_USED_FOR_LOCAL_CACHE_PURPOSES"
    />
  );
}

export default App;
```

The search function is expected to return an array of `DocSearchHit`, the internal type 
used by algolia documents. You will most likely have to write a function mapping your 
search results into this specific format:

```ts
export declare type DocSearchHit = {
  objectID: string;
  content: string | null;
  url: string;
  url_without_anchor: string;
  type: ContentType;
  anchor: string | null;
  hierarchy: {
    lvl0: string;
    lvl1: string;
    lvl2: string | null;
    lvl3: string | null;
    lvl4: string | null;
    lvl5: string | null;
    lvl6: string | null;
  };
  _highlightResult: DocSearchHitHighlightResult;
  _snippetResult: DocSearchHitSnippetResult;
  _rankingInfo?: {
    promoted: boolean;
    nbTypos: number;
    firstMatchedWord: number;
    proximityDistance?: number;
    geoDistance: number;
    geoPrecision?: number;
    nbExactWords: number;
    words: number;
    filters: number;
    userScore: number;
    matchedGeoLocation?: {
      lat: number;
      lng: number;
      distance: number;
    };
  };
  _distinctSeqID?: number;
};
```

Note: the search engine is fairly robust. Most of these params can be considered optional
with no decrease of functionality.

## Documentation

All other features are inline with docsearch, so I advise you to look
in the original docs:

[Read documentation →](https://docsearch.algolia.com/docs/DocSearch-v3)

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