MCPcopy
hub / github.com/algolia/autocomplete

github.com/algolia/autocomplete @v1.19.9 sqlite

repository ↗ · DeepWiki ↗ · release v1.19.9 ↗
856 symbols 2,273 edges 554 files 29 documented · 3%
README
<a href="https://www.algolia.com/doc/ui-libraries/autocomplete/introduction/what-is-autocomplete"><img src="https://github.com/algolia/autocomplete/raw/v1.19.9/media/banner.png" alt="Autocomplete" width="1280"></a>



    <strong>A JavaScript library that lets you quickly build autocomplete experiences</strong>

Version MIT License

All you need to get started is:

  • A container to inject the experience into
  • Data to fill the autocomplete with
  • Any Virtual DOM solution (JavaScript, Preact, React, Vue, etc.)

The data that populates the autocomplete results are called sources. You can use whatever you want in your sources: a static set of searches terms, search results from an external source like an Algolia index, recent searches, and more.

By configuring just those two required parameters (container and getSources) you can have an interactive autocomplete experience. The library creates an input and provides the interactivity and accessibility attributes, but you're in full control of the DOM elements to output.

Screenshot

DocumentationAPIPlayground

Installation

The recommended way to get started is with the autocomplete-js package. It includes everything you need to render a JavaScript autocomplete experience.

Otherwise, you can install the autocomplete-core package if you want to build a renderer from scratch.

All Autocomplete packages are available on the npm registry.

yarn add @algolia/autocomplete-js
# or
npm install @algolia/autocomplete-js

If you don't use a package manager, you can use the HTML script element:

<script src="https://cdn.jsdelivr.net/npm/@algolia/autocomplete-js"></script>
<script>
  const { autocomplete } = window['@algolia/autocomplete-js'];
</script>

Usage

To get started, you need a container for your autocomplete to go in. If you don't have one already, you can insert one into your markup:

```js title="HTML"


Then, insert your autocomplete into it by calling the [`autocomplete`](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/) function and providing the [`container`](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-js/autocomplete/#param-container). It can be a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement).

Make sure to provide a container (e.g., a `div`), not an `input`. Autocomplete generates a fully accessible search box for you.

```js title="JavaScript"
import { autocomplete } from '@algolia/autocomplete-js';

autocomplete({
  container: '#autocomplete',
  // ...
});

Continue reading our Getting Started guide.

Documentation

The documentation offers a few ways to learn about the Autocomplete library:

  • Read the Core Concepts to learn more about underlying principles, like Sources and State.
  • Follow the Guides to understand how to build common UX patterns.
  • Refer to API reference for a comprehensive list of parameters and options.
  • Try out the Playground where you can fork a basic implementation and play around.

You can find more on the documentation.

Support

Packages

Package Description Documentation
autocomplete-js JavaScript package for Autocomplete Documentation
autocomplete-core JavaScript core primitives to build an autocomplete experience Documentation
autocomplete-plugin-recent-searches A plugin to add recent searches to Autocomplete Documentation
autocomplete-plugin-query-suggestions A plugin to add query suggestions to Autocomplete Documentation
autocomplete-plugin-algolia-insights A plugin to add Algolia Insights to Autocomplete Documentation
autocomplete-plugin-redirect-url A plugin to enable redirect URLs Documentation
autocomplete-plugin-tags A plugin to manage and display a list of tags in Autocomplete Documentation
autocomplete-preset-algolia Presets to use Algolia features with Autocomplete Documentation
autocomplete-theme-classic Classic theme for Autocomplete Documentation

Showcase

See the awesome experiences people built with Autocomplete:

DocSearch Algolia Documentation

DocSearch

|

Algolia Documentation

|

Find more in our Showcase.

Sandboxes

Check out sandboxes using Autocomplete.

License

MIT

Extension points exported contracts — how you extend this code

SearchParams (Interface)
(no doc)
packages/autocomplete-shared/src/preset-algolia/createRequester.ts
AutocompleteContext (Interface)
(no doc)
packages/autocomplete-plugin-algolia-insights/src/index.d.ts
RedirectUrlPlugin (Interface)
(no doc)
packages/autocomplete-plugin-redirect-url/src/types/Redirect.ts
AutocompleteOptions (Interface)
(no doc)
packages/autocomplete-js/src/types/index.ts
OnKeyDownOptions (Interface)
(no doc)
packages/autocomplete-core/src/onKeyDown.ts
RecentSearchesPluginData (Interface)
(no doc)
packages/autocomplete-plugin-recent-searches/src/createRecentSearchesPlugin.ts
Matchers (Interface)
(no doc)
scripts/jest/matchers/toWarnDev.d.ts
BlurhashProps (Interface)
(no doc)
examples/two-column-layout/src/components/Blurhash.tsx

Core symbols most depended-on inside this repo

createPlayground
called by 225
test/utils/createPlayground.ts
autocomplete
called by 206
packages/autocomplete-js/src/autocomplete.ts
runAllMicroTasks
called by 111
test/utils/runAllMicroTasks.ts
createSource
called by 87
test/utils/createSource.ts
getState
called by 59
packages/autocomplete-core/src/types/AutocompleteStore.ts
createElement
called by 59
examples/vue/src/utils/createElement.js
createAutocomplete
called by 56
packages/autocomplete-core/src/createAutocomplete.ts
getAlgoliaResults
called by 53
packages/autocomplete-preset-algolia/src/requester/getAlgoliaResults.ts

Shape

Function 792
Interface 41
Method 23

Languages

TypeScript100%

Modules by API surface

packages/autocomplete-core/src/getPropGetters.ts18 symbols
packages/autocomplete-plugin-redirect-url/src/createRedirectUrlPlugin.ts15 symbols
packages/autocomplete-plugin-algolia-insights/src/createSearchInsightsApi.ts15 symbols
examples/tags-in-searchbox/app.tsx15 symbols
packages/autocomplete-shared/src/core/AutocompleteOptions.ts13 symbols
examples/tags-with-hits/app.tsx13 symbols
examples/instantsearch/src/autocomplete.tsx13 symbols
examples/github-notification-filters/app.tsx13 symbols
packages/autocomplete-plugin-recent-searches/src/createRecentSearchesPlugin.ts12 symbols
packages/autocomplete-plugin-redirect-url/src/__tests__/createRedirectUrlPlugin.test.ts11 symbols
packages/autocomplete-core/src/getDefaultProps.ts11 symbols
packages/autocomplete-plugin-algolia-insights/src/createAlgoliaInsightsPlugin.ts10 symbols

Dependencies from manifests, versioned

@algolia/autocomplete-core1.19.9 · 1×
@algolia/autocomplete-js1.19.9 · 1×
@algolia/autocomplete-plugin-algolia-insights1.19.9 · 1×
@algolia/autocomplete-plugin-query-suggestions1.19.9 · 1×
@algolia/autocomplete-plugin-recent-searches1.19.9 · 1×
@algolia/autocomplete-plugin-redirect-url1.19.9 · 1×
@algolia/autocomplete-plugin-tags1.19.9 · 1×
@algolia/autocomplete-preset-algolia1.19.9 · 1×
@algolia/autocomplete-shared1.19.9 · 1×
@algolia/autocomplete-theme-classic1.19.9 · 1×
@algolia/client-search4.16.0 · 1×
@babel/cli7.21.0 · 1×

For agents

$ claude mcp add autocomplete \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact