With a packaging system
If you have a JavaScript build tool (for example if you’ve created your project using the Vue command-line tool), you can install Vue InstantSearch from npm:Directly in your page
Vue works when you’re embedding it directly in an HTML page too. First add the two script tags:HTML
#app
div.
Vue
ais-instant-search
is the root Vue InstantSearch component.
All widgets must be wrapped within it
In a production environment, secure your API keys as environment variables.
Send click and conversion events
Capturing real-time user interactions as events gives you actionable insights via click and conversion metrics, and they help you increase your customer engagement and conversions. Events are used to activate Algolia features and products like NeuralSearch, Dynamic Re-Ranking, Query Categorization, Recommend, and Personalization. To send click and conversion events when users interact with your search UI, set theinsights
option to true
.
Optimize your build with tree shaking
Tree shaking can be done with modern build tools. The goal is to have code that’s actually used in your built site. In the context of Vue InstantSearch this means not including the widgets that aren’t used. You can do this by using the components directly, rather than theVue.use(InstantSearch)
call.
In every component you’re using InstantSearch widgets, you can import and instantiate them like this:
Browser support
Algolia supports the last two versions of the major browsers: Chrome, Edge, Firefox, Safari. To support Internet Explorer 11 you need polyfills for:Array.prototype.find
, Array.prototype.includes
, Promise
, Object.entries
, and Object.assign
.
The code samples in this documentation use a JavaScript syntax that isn’t natively supported by older browsers like Internet Explorer 11.
If your site needs to support older browsers, use a tool like Babel to make your code work in the browsers you target.