Prerequisites
Before you begin, you’ll need:- A Constructor.io account with an API key (sign up here)
- A modern browser or React Native environment
- npm, yarn, or pnpm installed
You can find your API key in the Constructor.io dashboard.
Installation
Install the package
Install the Constructor.io JavaScript client via your preferred package manager:
Complete Example
Here’s a complete working example that displays search results on a web page:Using async/await
For cleaner code, use async/await syntax:Adding Filters and Sorting
Enhance your search with filters and sorting:Tracking Events
Track user interactions to improve search results over time:Next Steps
Now that you have the basics working, explore more features:Client Configuration
Learn about all available configuration options
Search Guide
Advanced search features and best practices
Autocomplete
Add real-time search suggestions
Tracking Events
Understand the full tracking system
Troubleshooting
CORS Errors
If you encounter CORS errors, ensure your domain is whitelisted in your Constructor.io dashboard.Session Management
The client automatically manages session IDs via the@constructor-io/constructorio-id package. No manual cookie management is needed in browser environments.
React Native
For React Native apps, see the React Native guide for additional setup requirements.Get Help
- API Reference - Complete API documentation
- GitHub Issues - Report bugs or request features
- Constructor.io Support - Contact support team