Integration Guides
HTML / JavaScript Integration
The simplest way to add SearchX to any website using plain HTML and JavaScript.
Step 1: Add Required Scripts
Include React, ReactDOM, and the SearchX SDK in the <head> of your document:
<head>
<!-- React & ReactDOM -->
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- SearchX SDK -->
<script src="https://helloworld-pc.github.io/searchx-components/searchx-sdk.umd.js"></script>
</head>
Step 2: Add Container Elements
Place the container divs where you want the search UI to appear:
<body>
<!-- Search Bar (typically in your header) -->
<div id="search-bar"></div>
<!-- Search Results Page -->
<div id="search-page"></div>
</body>
Step 3: Initialize the SDK
Add the initialization script before the closing </body> tag:
<script>
window.addEventListener('load', function () {
if (window.SearchXSDK) {
SearchXSDK.init({
app_id: 'YOUR_APP_ID',
api_key: 'YOUR_API_KEY',
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
},
settings: {
wishlistEnabled: true,
showIcon: true,
},
});
}
});
</script>
Complete Example
Here's a full working HTML page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Store - Search</title>
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://helloworld-pc.github.io/searchx-components/searchx-sdk.umd.js"></script>
</head>
<body>
<header>
<h1>My Store</h1>
<div id="search-bar"></div>
</header>
<main>
<div id="search-page"></div>
</main>
<script>
window.addEventListener('load', function () {
SearchXSDK.init({
app_id: 'YOUR_APP_ID',
api_key: 'YOUR_API_KEY',
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
},
});
});
</script>
</body>
</html>
Next Steps
- See the SDK Reference for all configuration options.
- Learn about Widget Styling to customize the appearance.