Skip to main content

beforeAutocompleteAsyncFunction

Use this hook to run asynchronous work (for example, external API requests) before Autocomplete continues.

Parameters

This hook doesn’t accept parameters.

Returns

This hook doesn’t return a value. Return a Promise to delay Autocomplete until your work completes.

Examples

JavaScript

beforeAutocompleteConfigurationOptions

Modifies the global Autocomplete configuration before any plugin executes a . This hook runs on every keystroke and lets you customize search parameters, apply a , update analytics tags, or change other search query settings across all Autocomplete sources.

Parameters

object
Configuration object.
object
Context information.

Returns

object
Modified configuration object.

Examples

This example adds the tags autocomplete, products, and v2 to the search query for products only.
JavaScript
This example adds the filter tags:sale to the search, if the query includes the word sale.
JavaScript
This example adds custom ruleContexts to the product queries in Autocomplete.
JavaScript

beforeAutocompletePluginOptions

Customizes individual plugin options during plugin construction. This hook runs once per plugin at initialization time. Use the hook to set static defaults like base filters, analytics tags, or custom transform functions.

Parameters

object
Plugin options.
object
Context information.

Returns

object
Modified plugin options.

Examples

JavaScript
JavaScript

beforeAutocompletePluginsArray

Manages the plugin array before creating the Autocomplete instance. This hook runs once at initialization and lets you add and remove plugins, or reorder the plugin array.
To work with plugins, use the arguments object to extract them into an array.

Parameters

any[]
List of plugins passed to the Autocomplete instance.

Returns

any[]
Modified plugin list.

Examples

This example removes the articles and pages plugins.
JavaScript

beforeAutocompleteOptions

Use this hook to set or change Autocomplete options, such as the placeholder text.

Parameters

Returns

object
Modified Autocomplete options.

Examples

This example changes the placeholder text.
JavaScript

beforeAutocompleteFiltersString

Use this hook to add or override filters in the Autocomplete menu.

Parameters

string
Filters.

Returns

string
Modified filters.

Examples

This example returns a custom filter instead of the default.
JavaScript

beforeAutocompleteRedirectUrlOptions

Changes the default parameters of the createRedirectUrlPlugin function.

Parameters

object
Redirect URL plugin options.

Returns

object
Modified Redirect URL plugin options.

Examples

beforeAutocompleteMainTemplate

Changes the HTML template that renders the Autocomplete panel. Use this to render an Autocomplete multi-panel layout.

Parameters

Default template.
object
Template options including the html tagged template function.
object
Template elements.
boolean
Whether to render query suggestions.

Returns

Template to render.

Examples

This example returns a custom two-column layout as template.
JavaScript

beforeAutocompleteMainProductsTemplate

Renders the product section in the Autocomplete menu.

Parameters

Default template.
Template options including the html tagged template function.
object
Contains the products element.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteNoResultsTemplate

Renders a template when Autocomplete doesn’t return results.

Parameters

Default template.
Template options including the html and state properties.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteHeaderTemplate

Renders a header section at the top of the Autocomplete results panel.

Parameters

Default template.
Template options including the html and state properties.
string
Resource type.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteFooterTemplate

Renders a footer section at the bottom of the Autocomplete results panel. To render a footer, select the Show See All products option in the Autocomplete search options in your store’s admin.

Parameters

Default template.
Template options including the html and state properties.

Returns

Template to render.

Examples

beforeAutocompleteProductTemplate

Template for rendering each product hit in the Autocomplete results. If you are using this template, ensure you also call trackSearchAttribution(item) to properly handle events.

Parameters

Default template.
Template options including html, item, and components.
boolean
Whether distinct mode is enabled.
Product URL.
Function to track search attribution.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteArticlesTemplate

Template for rendering each article hit in the Autocomplete results.

Parameters

Default template.
Template options including html, item, and components.
Article URL.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteCollectionsTemplate

Template for rendering each collection hit in the Autocomplete results.

Parameters

Default template.
Template options including html, item, and components.
Collection URL.

Returns

Template to render.

Examples

JavaScript

beforeAutocompletePagesTemplate

Template for rendering each pages hit in the Autocomplete results.

Parameters

Default template.
Template options including html, item, and components.
Page URL.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteSuggestionsTemplate

Template for rendering each search suggestion in the Autocomplete menu.

Parameters

Default template.
Template options including html, item, and components.

Returns

Template to render.

Examples

JavaScript

beforeAutocompleteProductTransformResponseHits

Modifies the hits before rendering them in the Autocomplete menu. For more information, see transformResponse.

Parameters

array
Search results.
object
Full results from Algolia.

Returns

array
Modified search results.

Examples

JavaScript

afterAutocompleteProductClickAction (deprecated)

This hook is deprecated. Use beforeAutocompleteProductTemplate instead.
Adds a click handler function to the product template. Call this hook after a user clicks a product.

Parameters

any
First parameter (unused).
object
Product line item that was clicked.

See also

Last modified on May 19, 2026