![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@algolia/autocomplete-js
Advanced tools
@algolia/autocomplete-js is a JavaScript library that provides a highly customizable autocomplete experience. It is designed to be flexible and easy to integrate with various data sources, including Algolia's search API. The package allows developers to create powerful and responsive autocomplete interfaces with minimal effort.
Basic Autocomplete Setup
This code sets up a basic autocomplete interface with a static list of items. The `autocomplete` function initializes the autocomplete widget, and the `getSources` method defines the data sources for the autocomplete suggestions.
```javascript
import { autocomplete } from '@algolia/autocomplete-js';
autocomplete({
container: '#autocomplete',
getSources() {
return [
{
sourceId: 'example-source',
getItems() {
return [
{ label: 'Item 1' },
{ label: 'Item 2' },
{ label: 'Item 3' }
];
},
templates: {
item({ item }) {
return item.label;
}
}
}
];
}
});
```
Using Algolia Search API
This example demonstrates how to integrate the autocomplete widget with Algolia's search API. The `getItems` method performs a search query using Algolia's client and returns the search results as autocomplete suggestions.
```javascript
import { autocomplete } from '@algolia/autocomplete-js';
import algoliasearch from 'algoliasearch/lite';
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
autocomplete({
container: '#autocomplete',
getSources() {
return [
{
sourceId: 'products',
getItems({ query }) {
return searchClient
.initIndex('products')
.search(query)
.then(({ hits }) => hits);
},
templates: {
item({ item }) {
return item.name;
}
}
}
];
}
});
```
Customizing Autocomplete Templates
This code sample shows how to customize the templates used for rendering autocomplete suggestions. The `item` template is modified to include both a label and a description for each suggestion.
```javascript
import { autocomplete } from '@algolia/autocomplete-js';
autocomplete({
container: '#autocomplete',
getSources() {
return [
{
sourceId: 'example-source',
getItems() {
return [
{ label: 'Item 1', description: 'Description 1' },
{ label: 'Item 2', description: 'Description 2' },
{ label: 'Item 3', description: 'Description 3' }
];
},
templates: {
item({ item }) {
return `<div>
<strong>${item.label}</strong>
<p>${item.description}</p>
</div>`;
}
}
}
];
}
});
```
react-autosuggest is a React component for building autocomplete and autosuggest input fields. It is highly customizable and supports various data sources. Compared to @algolia/autocomplete-js, react-autosuggest is more focused on React applications and provides a more React-centric API.
downshift is a library that provides primitives to build flexible and accessible autocomplete, combobox, and dropdown components. It is framework-agnostic and can be used with React, Preact, or other libraries. Unlike @algolia/autocomplete-js, downshift offers lower-level building blocks, giving developers more control over the behavior and appearance of their components.
awesomplete is a lightweight, zero-dependency JavaScript library for creating autocomplete widgets. It is easy to use and highly customizable. Compared to @algolia/autocomplete-js, awesomplete is more lightweight and does not include built-in support for integrating with external APIs like Algolia.
The autocomplete-js
package is an agnostic virtual DOM renderer. You can use it in JavaScript, Preact, React, or Vue projects.
yarn add @algolia/autocomplete-js
# or
npm install @algolia/autocomplete-js
See Documentation.
FAQs
Fast and fully-featured autocomplete JavaScript library.
The npm package @algolia/autocomplete-js receives a total of 98,897 weekly downloads. As such, @algolia/autocomplete-js popularity was classified as popular.
We found that @algolia/autocomplete-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.