npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

auvi

v0.1.4

Published

Dependency-free vanilla JavaScript autocompletion library

Downloads

171

Readme

Table of contents

About the Project

Features

  • Vanilla JavaScript / no dependencies
  • Data fetching by predefined array or external url
  • Configuration by JavaScript object or data attributes
  • Customizable suggestion list items
  • Two variants: Tooltip and external list
  • Minimal styling / no bloated stylesheets / create your own styling

Getting Started

Installation

Install auvi with npm

  npm install auvi

Run Locally

Clone the project

  git clone https://github.com/jaybee111/auvi.git

Install dependencies

  npm install

Start the server

  npm run dev

Build source files

  npm run build

Run tests

  npm run test

Usage

import Auvi from 'auvi'

const myInputElement = document.querySelector('.my-input-element');
const auviInstance = new Auvi(myInputElement).init();

Options

Possible options

import Auvi from 'auvi'

const myInputElement = document.querySelector('.my-input-element');
const options = {
  mode: "external" | "tooltip",
  minInputLength: Number,
  options: Array<ResultOptionsItemInterface> | string,
  resultItemTemplate: (item: ResultOptionsItemInterface) => string,
  resultListTarget: HTMLElement | undefined,
  loader: () => string | undefined,
};
const auviInstance = new Auvi(myInputElement,options).init();

| Key | data-attribute | Type | Default value | |--------------------|---------------------------------------|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| | mode | data-mode | string | tooltip | | minInputLength | data-min-input-length | Number | 3 | | options | data-options (only for string type) | ResultOptionsItemInterface[], string | [] | | resultItemTemplate | only object notation | (item: ResultOptionsItemInterface) => string | (optionsItem: ResultOptionsItemInterface) => `${optionsItem.value}`; | | resultListTarget | only object notation | HTMLElement, undefined | undefined | | loader | only object notation | () => string, undefined | () => <div class="auvi-loading-indicator"><div></div><div></div><div></div><div></div></div> |

mode

Two modes are possible: tooltip and external.

Tooltip

The tooltip - mode shows the suggestion list as an absolutely positioned element below next to the input element.

const options = {
  mode: 'tooltip',
};
External

The external mode shows the suggestion list in a previously defined html element. Set the resultListTarget for this purpose.

const options = {
  mode: 'external',
  resultListTarget: document.querySelector('.my-result-list-target')
};
minInputLength

Sets the character length of the input field from which the search is started.

const options = {
  minInputLength: 3,
};
options

Sets the searchable suggestion list items. Every item should be structured like ResultOptionsItemInterface.

Array
const options = {
  options: [
    {
      value: 'Test 1'
    },
    {
      value: 'Test 2'
    },
    {
      value: 'Test 3'
    }
  ],
};
string / External URL
const options = {
    options: 'https://my-external-api.com/search?q={term}'
};

The placeholder {term} is mandatory and will be replaced with your search phrase. Auvi expects json from external sources.

resultItemTemplate

Sets the template for every suggestion list item. :heavy_exclamation_mark: There is no XSS-Injection check, if you use your own template.

const options = {
  resultItemTemplate(optionsItem: ResultOptionsItemInterface) {
    return `<strong>${optionsItem.value}</strong>`;
  },
};

Data attributes

<input
        type="text"
        value=""
        data-min-input-length="4"
        data-mode="tooltip"
        data-options="https://my-external-api.com/search?q={term}"
/>
resultListTarget

Sets the html element target for the suggestion list item.

const options = {
    resultListTarget: document.querySelector('.my-result-list-target')
};
loader

Sets the loader element.


const options = {
  loader() {
    return `<div class="my-new-loading-indicator"></div>`;
  },
}

Callbacks

resultItemClicked

import Auvi from 'auvi'

const myInputElement = document.querySelector('.my-input-element');
const auviInstance = new Auvi(myInputElement).init();
auviInstance.on('resultItemClicked', (item) => {
    console.log('Item clicked', item);
});

Events

init

Initialize Auvi

const myInputElement = document.querySelector('.my-input-element');
const auviInstance = new Auvi(myInputElement).init();

destroy

Destroy current instance

const myInputElement = document.querySelector('.my-input-element');
const auviInstance = new Auvi(myInputElement).init();
auviInstance.destroy();

Types/Interfaces

ResultOptionsItemInterface

ResultOptionsItemInterface {
  value: string,
  url?: string,
  additionalData?: Object,
}

Roadmap

  • :black_square_button: WAI-ARIA support
  • :black_square_button: Categorize suggestion list
  • :black_square_button: Add custom template support for suggestion list
  • :black_square_button: Add demo page with examples
  • :black_square_button: Add unit tests

License

This project is available under the MIT license.