Skip to main content

Upgrade from v4 to v5

Vue InstantSearch v5 is in beta.
Vue InstantSearch v5 removes deprecated components, props, and slot props, and changes some default behaviors. Changes shared with InstantSearch.js are in the InstantSearch.js upgrade guide. This section covers what’s specific to Vue InstantSearch. A codemod updates part of your JavaScript code, but it doesn’t update .vue files. The following table lists the changes in this guide.

Browser support

Vue InstantSearch v5 supports the same browsers as InstantSearch.js v5 and drops Internet Explorer 11. For the list of supported browsers, see Browser support. If you need to support older browsers, compile Vue InstantSearch with your build tooling.

Package structure

Vue InstantSearch v5 depends on the instantsearch-core package and no longer installs instantsearch.js. Some shared modules, such as instantsearch.js/es/lib/server and most utilities, moved to instantsearch-core. Imports from instantsearch.js/es and instantsearch.js/cjs paths, such as instantsearch.js/es/connectors, no longer resolve. Vue InstantSearch v5 re-exports the public API of instantsearch-core, such as connectors, routers, state mappings, and middleware. Import them from Vue InstantSearch instead of instantsearch.js. The router is historyRouter, and the state mappings are simpleStateMapping and singleIndexStateMapping.
JavaScript
If you keep imports from instantsearch.js, add it to your own dependencies. Import from instantsearch.js itself, because its instantsearch.js/es paths no longer resolve. The chat helpers, instantsearch.js/es/lib/suit, and most utilities aren’t public API in v5, so Vue InstantSearch doesn’t re-export them. Copy the code you need into your project. The chat tool type constants are an exception. Import SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, CompareProductsToolType, and GroupedResultsToolType from vue-instantsearch or its vue2/es and vue3/es entries. InstantSearch.js v5 removes DisplayResultsToolType. If you registered a custom tool under it, use the 'algolia_display_results' string as the key instead. The default grouped results tool still renders tool calls under that key. Vue InstantSearch v5 no longer publishes its src folder. Its builds are marked as side-effect-free, so build tools can remove the components you don’t use. Imports from vue-instantsearch/src/... break. Import from the build for your Vue version instead:
Vue
For Vue 2, import from vue-instantsearch/vue2/es. Vue InstantSearch v5 also adds an exports map to its package. You can import from vue-instantsearch, vue-instantsearch/vue2, vue-instantsearch/vue3, vue-instantsearch/vue2/es, vue-instantsearch/vue3/es, and the src/widgets.js file in each es build. Other paths, such as vue-instantsearch/vue3/cjs/index.js, no longer resolve. For more information, see Package structure.

Experimental components

Vue InstantSearch v5 removes ais-experimental-dynamic-widgets and ais-experimental-configure-related-items. Replace ais-experimental-dynamic-widgets with ais-dynamic-widgets. It takes the same props and slots.
Vue
ais-experimental-configure-related-items doesn’t have a direct replacement. To show related items, use ais-related-products, which gets recommendations from Algolia Recommend instead of changing search parameters.
Vue
To keep the previous behavior, copy the removed code into your project and update its imports: The component imports createWidgetMixin, which Vue InstantSearch v5 exports from vue-instantsearch. For more information, see Experimental widgets.

Autocomplete component

Vue InstantSearch v5 renames ais-experimental-autocomplete to ais-autocomplete. It takes the same props and slots, except for escapeHTML, which v5 removes. For more information, see Highlight and escaping.
Vue
If you import the component, rename AisExperimentalAutocomplete to AisAutocomplete. The codemod renames the import in JavaScript and TypeScript files. It doesn’t change .vue files. In v4, ais-autocomplete was a renderless component with the refine, current-refinement, and indices slot props. Vue InstantSearch v5 removes that component. ais-autocomplete renders the full autocomplete. If you use the renderless component, build a custom widget with connectAutocomplete and createWidgetMixin instead. To copy the removed component, see Autocomplete.vue in vue-instantsearch@4.33.0. Import connectAutocomplete, createSuitMixin, and createWidgetMixin from vue-instantsearch instead of the relative paths.

Removed InstantSearch.js widgets

InstantSearch.js v5 removes the places, analytics, answers, and filter suggestions widgets and their connectors. Vue InstantSearch doesn’t have components for these widgets. If you use their connectors in custom Vue widgets, see the following migration guides:

search-function prop

ais-instant-search doesn’t accept the search-function prop anymore. Move your logic to the on-state-change prop. It runs when the UI state changes, not before each search. When you use on-state-change, call setUiState to apply the state.
Vue
This release also removes other deprecated instance and widget APIs, such as addWidget, removeWidget, and searchMetadata. If your custom widgets use them, see Instance and index APIs. Vue InstantSearch v5 removes the preserveSharedStateOnUnmount and persistHierarchicalRootCount options of the future prop of ais-instant-search, because both behaviors are always on. Remove the :future binding. If you keep them, Vue InstantSearch ignores them and doesn’t log a warning.

has-no-results slot prop

The default slots of ais-sort-by and ais-hits-per-page don’t expose has-no-results anymore. Use can-refine instead. For ais-hits-per-page, it’s false when the search doesn’t return any results.
Vue
For ais-sort-by, can-refine is also false when there are no sort options, so it isn’t an exact replacement for has-no-results. The default slots of ais-numeric-menu and ais-rating-menu never exposed has-no-results, so they don’t need any change. Other slot props keep their names. ais-search-box still exposes is-search-stalled, and ais-clear-refinements still exposes can-refine. If your custom widgets read render state fields from connectors, such as hits or isSearchStalled, see Render state fields.

Highlight and escaping

Vue InstantSearch v5 no longer escapes hits and facet values. It removes these props: The _highlightResult and _snippetResult values, and the highlighted value of refinement list items, now contain __ais-highlight__ placeholders instead of <mark> tags. The ais-highlight, ais-reverse-highlight, ais-snippet, and ais-reverse-snippet components replace the placeholders with highlight tags.
These values aren’t HTML-escaped. Don’t render them with v-html. Untrusted content could introduce executable scripts or event handlers.
Vue
For the other cases to check, see Highlight and escaping.

Default hit rendering

When you don’t provide an item slot, ais-hits and ais-infinite-hits render each hit as indented JSON. Vue InstantSearch v4 rendered the text objectID: OBJECT_ID, index: INDEX. Vue InstantSearch v5 renders the full hit. Update tests or snapshots only if they depend on the default output.

Chat tool and empty slot props

Custom tool layouts in ais-chat only receive the context prop. Read values such as message, status, onClose, and addToolResult from context. The empty slot works the same way: it only receives context.
Vue
For more information, see Chat template props.

Insights client and event tracking

Vue InstantSearch v5 removes the insights-client prop of ais-instant-search. The prop no longer has any effect. InstantSearch doesn’t warn you. Pass the client in the insights prop:
Vue
The default and item slots of ais-hits and ais-infinite-hits no longer expose the insights function. Use sendEvent instead. For more information, see Insights client and event tracking.

State results and clear refinements

Vue InstantSearch v5 makes these markup changes:
  • ais-clear-refinements no longer sets type="reset" on its button.
  • The ais-state-results slot only receives results, state, status, and error. The slot previously exposed properties such as query and hits directly. Read these values from results instead.
Vue

Shared changes

These changes come from InstantSearch.js and the Algolia search helper. They affect the future prop, custom widgets, and routing:

Upgrade event tracking

Starting from v4.9.0, Vue InstantSearch simplifies the event tracking process with the insights option. You no longer need to install the search-insights library or set up the insights middleware yourself. Here are some benefits when using the insights option:
  • It better handles the . Once you set it, all search and event tracking calls include the token.
  • It automatically sends default events from built-in widgets such as ais-refinement-list, ais-menu, etc. You can also change the event payloads, or remove them altogether.
  • It lets you send custom events from your custom widgets.
  • It simplifies forwarding events to third-party trackers.
If you’ve been tracking events directly with search-insights or with the insights middleware, follow these steps:
  1. Upgrade Vue InstantSearch to v4.9.0 or greater
  2. Migrate from using the insights middleware to the insights option
  3. Either update or remove the search-insights library

Use the Insights option

Starting from v4.9.0, Vue InstantSearch lets you enable event tracking with the insights option. You no longer need to set up the insights middleware yourself.
Vue
If you had already set up the insights middleware in your code, you can now remove it and move its configuration to the insights option.
Vue

Update search-insights

Starting from v4.9.0, Vue InstantSearch can load search-insights for you so the insightsClient option is no longer required. If you prefer loading it yourself, make sure to update search-insights to at least v2.4.0 and forward the reference to insights. If you’re using the UMD bundle with a script tag, make sure to update the full code snippet (not just the version):
HTML
If you’re using a package manager, you can upgrade it to the latest version.
Now you can pass the reference to the insights option.
Otherwise, you can remove it and let Vue InstantSearch handle it for you.

Remove search-insights

Starting from v4.9.0, Vue InstantSearch loads search-insights for you from jsDelivr if not detected in the page. If you’ve installed search-insights, you can now remove it. If you’re using the UMD bundle with a script tag, you can remove the snippet in any page that uses Vue InstantSearch:
HTML
If you’re using a package manager, you can remove it from your dependencies.
Then you can remove the reference to search-insights from your code:
Vue InstantSearch loads search-insights from the jsDelivr CDN, which requires that your site or app allows script execution from foreign resources. Check the security best practices for recommendations.

Upgrade from v3 to v4

You can use Vue InstantSearch v4 with Vue 2 and Vue 3.

Server-side rendering

Using Vue InstantSearch v4 introduces one breaking change in the server-side rendering. findResultsState in serverPrefetch now takes component and renderToString: (app) => Promise<string> in the first argument.

Vue 3

JavaScript

Vue 2

The renderToString function from vue-server-renderer/basic is callback-based. You need to promisify it like this:
JavaScript

If you upgrade to Vue 3

Import the library

The path to import Vue InstantSearch has changed for Vue 3, and is now:
JavaScript

Vue Router v4

If you’re using Vue Router and upgrading it to v4, currentRoute is now a reference instead of an object.
JavaScript
It’s not directly related to Vue InstantSearch, but if you are upgrading to Vue Router 4 along with Vue 3, you will encounter this issue anyway. It’s mentioned here for your information.

Upgrade from v2 to v3

This guide contains all the major changes that were introduced in v3, and how to migrate from v2. Vue InstantSearch v3 uses InstantSearch.js v4, so all breaking changes using the InstantSearch.js API also apply here. You can find more information in its respective upgrade guide.

Federated search (multi-index)

If you were using a ais-configure or a ais-search-box to synchronize between two ais-instant-search instances, you can now replace either one of them with the new ais-index widget like this:
Vue

ais-autocomplete

The indices option has been removed in favor of ais-index. This means that:
Vue
Should be replaced with:
Vue

ais-state-results

This widget used to expose the search results only, you can now access the search parameters as well. This lets you use information to perform view logic instead of waiting for the response to retrieve the data.
Vue
The results you have access to are always scoped to the current .

Routing and URLs

Since the introduction of federated search, it’s now possible to have multiple indices in a single app. This means that the default state mapping for routing now takes multiple indices into account. If you want to keep on using the same URLs as before, make the following change:
JavaScript
For more information about custom routers, consult the InstantSearch.js upgrade guide.

Server-side rendering (SSR)

This major version of Vue InstantSearch also includes an overhaul of the server-side rendering implementation. This takes two points into consideration:
  • work fully with serverPrefetch
  • no repetition needed between the template and parameters
To do this the following changes have been made:
  1. createInstantSearch -> createServerRootMixin
    JavaScript
  2. Using a compatible router The default routers in InstantSearch.js are based around browser location, and thus won’t work on the server. An example router for Vue SSR can be made like this:
    JavaScript
A full example can be found in the GitHub repository. Read more detail in the dedicated SSR guide.

Helper v3.x.x

This release includes version 3 of the algoliasearch-helper package. If you are using the built-in widgets or connectors, nothing changes for you. This version of algoliasearch-helper no longer includes Lodash, which significantly reduces its bundle size (from 27.5 KB to 9.1 KB Gzipped).

Upgrade from v1 to v2

This guide contains all the major changes that were introduced in v2 and how to migrate from v1. You can still find the documentation for Vue InstantSearch v1.

Renamed components

Some components have been renamed to be more consistent with other InstantSearch flavors.
  • ais-results -> ais-hits
  • ais-tree-menu -> ais-hierarchical-menu
  • ais-clear -> ais-clear-refinements
  • ais-results-per-page-selector -> ais-hits-per-page
  • ais-rating -> ais-rating-menu
  • ais-sort-by-selector -> ais-sort-by
  • ais-index -> ais-instant-search
All individual component exports have also been renamed from, for example, SearchBox to AisSearchBox. This is to make it more ergonomic to use them as components in a Vue file with the same name as expected. The Component mixin has been renamed to createWidgetMixin({ connector }). Read more about that in the custom component guide.

New components

  • ais-configure This widget is the replacement of query-parameters on ais-index.
  • ais-state-results This component can be used for conditional rendering, and getting information that’s not returned in ais-hits.
  • ais-breadcrumb To be used together with ais-hierarchical-menu.
  • ais-menu-select A single-selectable menu, rendered inside a select
  • ais-current-refinements Shows the current refinements, and allows them to be unset.
  • ais-infinite-hits Replaces :stack="true" on ais-results (now called ais-hits).
  • ais-numeric-menu Statically set numerical ranges can be used to refine using this widget.
  • ais-panel Wrap a widget in ais-panel to be able to give it a header and a footer. Replaces those options on each widget.
  • ais-toggle-refinement Toggle a boolean refinement either refined/unrefined or refinement/another refinement. Useful for toggles or buttons with two states.

Renamed options

Some options have been renamed. Largely those are:
  • attribute-name -> attribute
  • results -> hits
  • anything in a list -> items / item
  • header / footer -> wrap the widget in an ais-panel
If you see anything not mentioned here, complete the feedback form.

Removed options

  • query-parameters This is now handled with the ais-configure widget. Each query parameter becomes a prop on Configure.
  • query You can now synchronize the query across indices either by using a v-model on two ais-search-boxes of which you hide one, or with ais-configure on both indices, and synchronizing between those like that.
  • appId and apiKey This is now handled by the search-client prop. Search client is what gets returned if you call algoliasearch.
    Vue
  • :stack="true" When you used to put this on ais-results (now called ais-hits), it allows to load next pages without pagination, but with a “next page” button, as well as showing all pages rather than a single one. Replaced by ais-infinite-hits.
  • auto-search This option is removed in favor of a more complete way of not doing queries using the search client. For more information, see Conditional requests.

Removed components

  • ais-input This component has been removed with as alternative having two options:
    1. use ais-search-box and style it to not include the extra items
    2. use the default slot of ais-search-box to use it with your own custom input (see live):
    Vue

CSS class names

All CSS class names are now different, since Algolia follows the SUIT CSS methodology now, rather than the previous, slightly wrong, implementation of ‘block, element, and modifier’ (BEM). Since the DOM output is also different in most widgets, it’s best to start styling over from scratch on these widgets. Each widget lists the CSS classes it uses in its documentation page.

Known limitations

SSR (server-side rendering)

The implementation of server-side rendering with Vue InstantSearch slightly changed, with a simpler API. Read more on how to use it in the SSR guide.

Search store

The search store no longer exists. Custom widgets are either made by making a connector, or a combination of new widgets. You no longer need to copy a widget to give it custom rendering. Now you can fill in the default slot, which will have everything needed to render that component. If you’re using this, and have suggestions or questions, complete the feedback form.

Routing

You’re now able to use routing in InstantSearch with, or without Vue Router. It’s possible to change props on ais-instant-search, except routing. If you have a need for that to be changed as well, complete the feedback form.
Last modified on November 23, 2026