Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Product Discovery data & events

The Product Discovery drop-in uses the Event Bus to emit and listen to events for communication between drop-ins and external integrations. For common events shared across multiple drop-ins (such as locale, error, authenticated, etc.), see the Common Events Reference.

Emits Reference

Listens Reference

Emits and Listens Reference

Bidirectional events that both emit state changes and listen for external updates.

EventDirectionDescription
search/errorEmits and ListensTriggered when an error occurs
search/loadingEmits and ListensTriggered when loading state changes
search/resultEmits and ListensTriggered when results are available

Event Details

The following sections provide detailed information about each event, including its direction, data payload structure, and usage examples.

search/error (emits and listens)

Triggered when an error occurs

Data payload

string

Usage

Listen to this event in your storefront:

import { events } from '@dropins/tools/event-bus.js';
const searchErrorListener = events.on('search/error', (data) => {
console.log('search/error event received:', data);
// Add your custom logic here
});
// Later, when you want to stop listening
searchErrorListener.off();

search/loading (emits and listens)

Triggered when loading state changes

Data payload

boolean

Usage

Listen to this event in your storefront:

import { events } from '@dropins/tools/event-bus.js';
const searchLoadingListener = events.on('search/loading', (data) => {
console.log('search/loading event received:', data);
// Add your custom logic here
});
// Later, when you want to stop listening
searchLoadingListener.off();

search/result (emits and listens)

Triggered when results are available

Data payload

{
result: ProductSearchResult;
request: SearchVariables;
}
PropertyTypeDescription
resultProductSearchResultSee type definition in source code
requestSearchVariablesSee type definition in source code

Usage

Listen to this event in your storefront:

import { events } from '@dropins/tools/event-bus.js';
const searchResultListener = events.on('search/result', (data) => {
console.log('search/result event received:', data);
// Add your custom logic here
});
// Later, when you want to stop listening
searchResultListener.off();