Open Search
Opens the search bar inside the app
Description
The openSearch action opens the native product search screen within the Superfans app.
It allows users to explore your catalog using Shopify’s built-in search, including autocomplete and filtering features, all without leaving the app environment.
Function Signature
VajroSDK.actions.openSearch()Response of Status
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Search page opened successfully" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
document.getElementById('searchButton').addEventListener('click', () => {
VajroSDK.actions.openSearch();
});<div class="search-container">
<button class="search-btn" id="searchButton">Search</button>
</div>.search-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.search-btn {
background-color: #007bff;
color: #fff;
border: none;
padding: 15px 30px;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.search-btn:hover {
background-color: #0056b3;
}
.search-image {
width: 50px;
height: 50px;
cursor: pointer;
transition: transform 0.3s;
}
.search-image:hover {
transform: scale(1.1);
}Best Practices
- Use for global search triggers: Bind to header search icons or floating buttons.
- Pre-fill relevant terms: Use query to guide users toward specific product lines or promotions.
- Combine with analytics: Track which search queries are triggered programmatically.
- Provide search access points: Add it in home pages, banners, or “Explore” CTAs for better discovery.
- Avoid blocking actions: Allow users to return easily after completing a search.
Caveats
- App-only context: Works exclusively within the Superfans mobile app.
- Search scope: Results are limited to products and collections indexed in Shopify.
- No event return: The SDK does not return search results to JavaScript; it only opens the search view.
- Async behavior: Handle the Promise response to ensure UI consistency.
Updated about 1 month ago