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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@van1s1mys/ai-router

v1.2.1

Published

Semantic search routing using AI embeddings — find the best route by meaning, not keywords

Readme

@van1s1mys/ai-router

npm GitHub

Semantic search routing for SPAs — find the best route by meaning, not keywords.

Documentation | Live Demo | npm | GitHub

Runs a HuggingFace embedding model inside a Web Worker and uses Orama hybrid (text + vector) search to match user queries by semantic similarity.

Install

npm install @van1s1mys/ai-router

Usage

import { SmartRouter } from '@van1s1mys/ai-router';

const router = new SmartRouter({
  routes: [
    { path: '/pricing', title: 'Pricing', description: 'cost, plans, subscription' },
    { path: '/contact', title: 'Contact', description: 'support, phone, address' },
    { path: '/docs',    title: 'Docs',    description: 'documentation, API, guides' },
  ],
  threshold: 0.5,
});

await router.ready; // model loads (~22 MB, cached after first run)

const result = await router.search('how to reach support?');
// { path: '/contact', score: 0.91 }

router.destroy(); // cleanup when done

Progressive model loading

Start with a fast model, upgrade to a better one in the background:

const router = new SmartRouter({
  routes,
  model: ['Xenova/all-MiniLM-L6-v2', 'Xenova/multilingual-e5-small'],
  onModelUpgrade: (modelId) => console.log(`Upgraded to ${modelId}`),
});

await router.ready; // first model ready — search works immediately

Instance caching & preloading

// Pre-warm at page load
SmartRouter.preload({ routes, model: ['Xenova/all-MiniLM-L6-v2', 'Xenova/multilingual-e5-small'] });

// Later — returns cached instance, no re-download
const router = SmartRouter.create({ routes, model: ['Xenova/all-MiniLM-L6-v2', 'Xenova/multilingual-e5-small'] });
await router.ready; // instant if preload finished

Multilingual support

The default model (Xenova/all-MiniLM-L6-v2) works best for English. For other languages, use the multilingual model:

const router = new SmartRouter({
  routes,
  model: 'Xenova/multilingual-e5-small',
});

API

new SmartRouter(options)

| Option | Type | Default | Description | |---|---|---|---| | routes | RouteConfig[] | required | Routes to index | | model | string \| string[] | "Xenova/all-MiniLM-L6-v2" | Model ID or ordered array for progressive loading | | threshold | number | 0.5 | Minimum similarity score (0-1) | | onModelUpgrade | (modelId: string) => void | — | Called when the router switches to the next model |

SmartRouter.create(options): SmartRouter

Returns a cached instance for the given model config. Safe to call on every component mount.

SmartRouter.preload(options): SmartRouter

Same as create(), but intended to be called at page load to pre-warm the model.

router.ready: Promise<void>

Resolves when the first model is loaded and routes are indexed. Resolves immediately during SSR.

router.search(query): Promise<SearchResult | null>

Returns { path, score } or null if no route meets the threshold. Returns null during SSR.

router.destroy()

Terminates the worker, cleans up resources, and removes from cache. Safe to call multiple times.

SSR

SSR-safe out of the box. On the server ready resolves immediately and search() returns null. The worker is only spawned in the browser.

Framework plugins

Auto-scan your pages directory instead of listing routes manually:

License

MIT © IvanMalkS