Configuration
SDK Reference
Complete reference for every configuration option you can pass to the SearchX widget.
Initialization
The widget is initialized by calling SearchXSDK.init() once on your page with a configuration object:
SearchXSDK.init({
app_id: 'YOUR_APP_ID',
api_key: 'YOUR_API_KEY',
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
},
settings: {
/* feature toggles + UI options — see sections below */
},
});
Every option except the credentials and components is optional. Leave a setting out to keep the SDK default.
Top-level parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
app_id | string | Yes | Your Application ID, available from the Applications page in the SearchX dashboard. |
api_key | string | Yes | The public API key for this application, available from the Keys tab in the SearchX dashboard. |
components | object | Yes | DOM containers the widget mounts into. See the Components object section below. |
apiPageURL | string | No | Base URL for the SearchX API. Defaults to the production endpoint and only needs to be set if you're targeting a non-production environment. |
customCSSUrl | string | No | URL to a custom CSS file that overrides the default widget styles. See Widget Styling. |
customLocaleUrl | string | No | URL template for translation files. Use {{lng}} as a placeholder for the language code (e.g. /locales/{{lng}}.json). |
defaultLanguage | string | No | Initial language code (e.g. en, el). When omitted the widget auto-detects from the visitor's browser. |
settings | object | No | Nested object with the per-feature toggles documented in the sections below. |
Components object
The components object tells the widget where to render. Both keys are optional independently — render only the search bar, only the results page, or both.
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
}
| Property | Description |
|---|---|
SearchBar.root or SearchBar.roots[] | DOM element ID where the search bar mounts. Use roots: ['id-1', 'id-2'] when the same bar appears in more than one place on the page (e.g. desktop header + mobile drawer). |
SearchPage.root or SearchPage.roots[] | DOM element ID where the search results page mounts. Same roots[] pattern available. |
The target elements must exist in the DOM before init() runs and must be empty.
Settings — Layout & behaviour
High-level controls for where the widget routes searches, the platform integration mode it should use, and how pagination behaves.
| Setting | Type | Default | Description |
|---|---|---|---|
searchPageURL | string | — | URL the search bar navigates to when the shopper submits a query. Use {query} as a placeholder for the typed text — e.g. /search?q={query}. |
mobileViewPort | string | number | "900px" | Breakpoint at which the widget switches to its mobile layout. |
platform | "opencart" | "custom" | "other" | "opencart" | Controls how the widget delivers Add to Cart / Add to Wishlist actions. "opencart" triggers the built-in OpenCart cart integration. "custom" / "other" dispatch DOM events your storefront can listen to (see Event Handling). |
compactPagination | boolean | false | Renders the compact pagination control beneath search results. |
defaultProductsPerPage | 12 | 24 | 36 | 48 | 24 | Initial number of products shown per page in the search results grid. Shoppers can still change the per-page value from the toolbar. |
defaultPlaceholder | string | — | Custom placeholder text for the empty search input. |
topSearches | string[] | — | Manual list of popular search terms shown as suggestions in the search bar popup. Usually managed from the SearchX dashboard instead — the widget fetches that list automatically at runtime. |
Settings — Search bar popup
Controls the small popup that opens beneath the search bar while the shopper is typing — top searches, recent searches, featured products, and promotional links.
| Setting | Type | Default | Description |
|---|---|---|---|
showPopupAddToCart | boolean | false | Show a quick Add to Cart action next to each product result inside the search bar popup. |
showPopupSearchIcon | boolean | true | Show the small magnifier glyph next to each Recent search and Top search suggestion in the popup. Set to false for a cleaner text-only list. |
suggestedLinks | SuggestedLink[] or Record<string, SuggestedLink[]> | — | Promotional links rendered as chips inside the search bar popup. Normally managed from the SearchX dashboard (Suggested Links), but can also be passed inline for previews. Two shapes accepted — a flat array, or a per-locale map (e.g. { en: [...], el: [...] }) when you want different titles per language. |
Settings — Product cards
What metadata each product card displays in the search results grid, and which shopper actions are surfaced on the card.
| Setting | Type | Default | Description |
|---|---|---|---|
showBrand | boolean | false | Show the brand name on product cards. |
showSizes | boolean | false | Show available sizes on product cards. |
showColor | boolean | false | Show the product colour on product cards. |
showDescription | boolean | false | Show the product description on product cards. |
showSalePrice | boolean | false | Show the sale price with the original price struck through. Requires a sale_price on your products. |
showAddToCartButton | boolean | true | Show the Add to Cart button on each product card in the search results grid. |
wishlistEnabled | boolean | false | Show the Add to Wishlist heart icon on product cards. |
cartButtonText | string | — | Custom label for the Add to Cart button. Leave blank to use the default translation. |
wishlistButtonText | string | — | Custom label for the Add to Wishlist button. Leave blank to use the default translation. |
Settings — Filter sidebar
Which facet panels appear in the filter sidebar of the search results page. Each toggle is independent — turn on only the panels that match your catalogue.
| Setting | Type | Default | Description |
|---|---|---|---|
showBrandFacet | boolean | true | Show the Brand facet in the filter sidebar. |
showCategoryFacet | boolean | false | Show the Categories facet in the filter sidebar. |
showPriceRangeFilter | boolean | true | Show the price range filter (slider + min/max inputs). |
showOnSaleFacet | boolean | false | Show the On Sale toggle. Filters results to products that have a positive sale price below the regular price. Opt-in — requires a sale_price on your indexed products. |
showSizeFilter | boolean | false | Show the Size facet in the filter sidebar. |
showColorFilter | boolean | false | Show the Colour facet in the filter sidebar. |
Settings — AI Search
AI-assisted search is configured from the SearchX dashboard. The widget-side toggle below lets you opt the widget in or out at runtime.
| Setting | Type | Default | Description |
|---|---|---|---|
aiSearchEnabled | boolean | false | Enable the AI Search experience inside the widget. |
aiSearchChips | string[] or Record<string, string[]> | — | Prompt chips shown in the AI Search panel. Same per-locale shape as suggestedLinks — flat array, or { en: [...], el: [...] }. Normally managed from the SearchX dashboard. |
Deprecated settings (still supported)
These settings continue to work for backward compatibility, but new integrations should use the explicit replacements below. The widget treats the new key as authoritative whenever both are set.
| Deprecated | Replacement | Notes |
|---|---|---|
showIcon | showPopupAddToCart | Renamed for clarity — it controls the popup's quick Add to Cart action, not a generic icon. |
showBothFacets | showBrandFacet + showCategoryFacet | Use the two explicit toggles to show either, both, or neither facet. |
showCategory | showCategoryFacet | Renamed to match the rest of the explicit facet toggles. |
primaryFacetAttribute | showBrandFacet + showCategoryFacet | The two explicit toggles cover every combination the old setting supported. |
Full example
A complete init() call with every section represented. Trim to the settings your storefront actually needs — leaving the rest out keeps you on safe defaults.
SearchXSDK.init({
app_id: 'YOUR_APP_ID',
api_key: 'YOUR_API_KEY',
apiPageURL: 'https://admin.searchxengine.ai/api/v1',
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
},
customCSSUrl: '/assets/theme.css',
customLocaleUrl: '/assets/i18n/{{lng}}.json',
defaultLanguage: 'en',
settings: {
// Layout & behaviour
searchPageURL: '/search?q={query}',
mobileViewPort: '900px',
platform: 'custom',
compactPagination: true,
defaultProductsPerPage: 24,
defaultPlaceholder: 'Search for products...',
// Search bar popup
showPopupAddToCart: true,
showPopupSearchIcon: true,
// Product cards
showBrand: true,
showSizes: true,
showColor: true,
showDescription: false,
showSalePrice: false,
showAddToCartButton: true,
wishlistEnabled: true,
cartButtonText: 'Buy Now',
wishlistButtonText: 'Save for later',
// Filter sidebar
showBrandFacet: true,
showCategoryFacet: true,
showPriceRangeFilter: true,
showOnSaleFacet: false, // opt-in; requires sale_price on indexed products
showSizeFilter: true,
showColorFilter: true,
// AI search
aiSearchEnabled: false,
},
});
Related
- Quick Start — Smallest possible install.
- Widget Styling — Theme the widget with CSS variables and override component selectors.
- Suggested Links — How the dashboard-managed promotional chips work.
- URL Filters — Deep-link to filtered search results.
- Event Handling — Handle cart and wishlist clicks on custom platforms.