Algolia Autocomplete

repository·next·Indexed 26 days ago

https://github.com/algolia/autocomplete

A JavaScript library for building interactive, accessible, and customizable autocomplete search experiences. It provides core logic and accessibility via @algolia/autocomplete-core, a standard implementation via @algolia/autocomplete-js, and a suite of plugins for recent searches, query suggestions, Algolia Insights, redirect URLs, and tags. It also includes @algolia/autocomplete-preset-algolia for search engine utilities and @algolia/autocomplete-theme-classic for a customizable starter design.

Tokens
4K
Snippets
12
Records
42
Agent score
50%

What's inside Algolia Autocomplete

  1. Install Autocomplete via CDN

    next

    If you are not using a package manager, you can include Autocomplete using an HTML script element from a CDN.

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

    next

    The recommended way to get started is with the @algolia/autocomplete-js package, which includes everything needed to render a JavaScript autocomplete experience. You can install it via npm or yarn.

    Alternatively, if you want to build a custom renderer from scratch, you can install @algolia/autocomplete-core instead.

    yarn add @algolia/autocomplete-js
    # or
    npm install @algolia/autocomplete-js
  3. Initialize Autocomplete with autocomplete()

    next

    To use Autocomplete, you must provide a container (a CSS selector or an HTMLElement) where the experience will be injected.

    Important: The container should be a layout element like a div, not an input. Autocomplete will automatically generate a fully accessible search box for you inside the container.

    You must also provide getSources to define the data that populates the results.