@noction/vue-use-flexsearch

Vue wrapper for Flexsearch
3,260 18
Install
npm install @noction/vue-use-flexsearch
Latest Version:1.1.7
Vue:3
Older releases:2
License:MIT
Last Updated:Jan 16, 2026
Links: GitHub  ·  npm
Maintainer: melrose1

useFlexSearch

NPM version NPM downloads codecov

Wrapper for Flexsearch.

Install

pnpm add flexsearch @noction/vue-use-flexsearch

API

// eslint-disable-next-line unused-imports/no-unused-vars
function useFlexSearch<T extends Record<'id', Id>, D = unknown>(
  query: Ref<string>,
  providedIndex: Ref<Index | Document<D> | null>,
  store?: Ref<Array<T>>,
  searchOptions: SearchOptions = {},
  limit = 10,
): { results: ComputedRef<T[]> }

By utilizing the useFlexSearch composable, you can provide your search query, index, and store as inputs, and obtain the results as an array. This optimizes searches by memoizing them, ensuring efficient searching.

Parameters

Name Type Description Default
query Ref The keyword which we are looking for
providedIndex Ref The Index or Document from Flexsearch
store Ref<Array The list of item where we are looking
searchOptions Object Search options {}
limit 10 Max number of results to be returned 10

Usage

This code snippet creates a text input field and utilizes FlexSearch to execute a search on the index when the query is changed.

<script setup>
import { useFlexSearch } from '@noction/vue-use-flexsearch'
import { Index } from 'flexsearch'
import { ref, shallowRef } from 'vue'

const store = ref([
  { id: 1, title: 'The Jungle Book' },
  { id: 2, title: 'Dracula' },
  { id: 3, title: 'Shōgun' },
])

const index = shallowRef(new Index({ preset: 'match' }))

store.value.forEach(item => index.value.add(item.id, item.title))

const query = ref('')
const { results } = useFlexSearch(query, index, store)
</script>

<template>
  <div>
    <input v-model="query">
    <h1>Results</h1>
    <ul>
      <li v-for="result in results" :key="result.id" v-text="result.title" />
    </ul>
  </div>
</template>

Related Packages

@noction/hippie-nav

The "hippie-nav" module is a lightweight and dependency-free utility designed to...

576 6
vueuse-temporals

Date related composables for atmosphere-ui

1,676 1
@appbaseio/reactivesearch-vue

A Vue UI components library for building search experiences

36,027 4,920
@alvarosabu/ui

UI Library for my personal projects

14,634 5
@orbisk/vue-use-media-recorder

🪝 Vue Composable around MediaRecorder API

12,546 2

Version History

Version Released Vue License
1.1.7 ^3.3.4 MIT
1.1.6 ^3.3.4 MIT
1.1.5 ^3.3.4 MIT
1.1.4 ^3.3.4 MIT
1.1.3 ^3.3.4 MIT