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

nfts

v1.0.0

Published

An FTS server for static blogs; uses SQLite under the hood.

Readme

Naif Full Text Search

An FTS server for static blogs; uses SQLite under the hood.

Use this if:

  • your blog gets generated from markdown files that contain front matter;
  • you can run a very small Node.js server somewhere (with 0 npm dependencies).

Installation

Node 24+.

$ npm -g i nfts

Creating a database

$ nfts-add -o db.sqlite3 file1.md file2.md ...

The front matter in .md files is paramount: w/o it, nfts-add won't find a subject for a blog post, its authors, &c.

nfts-add appends data to the DB, so you can update it incrementally, but usually it's easier to remove the DB file before running nfts-add, & regenerate the DB every time you write a new blog post.

Serving & querying the index

$ nfts-server db.sqlite3

It'll print host+port values. The server only reads q search parameter, & returns an array of JSON objects:

$ curl -s http://localhost:3000/?q=omg | jq
[
  {
    "file": "2019/10/06/YkrSmi.md",
    "subject": "Being early is on-time",
    "date": 1570320000,
    "snippet": "...One of the genius programmers on the database side claimed that \"\u0002OMG\u0003, Linux causes data loss...",
    "tags": [ "quote", "ойті" ],
    "authors": [ "ag" ]
  },
  {
    "file": "2017/09/12/indent-region-in-the-emacs-batch-mode.md",
    "subject": "'indent-region' in the Emacs batch mode",
    "date": 1505174400,
    "snippet": "...",
    "tags": [ "ойті" ],
    "authors": [ "ag" ]
  }
]

Rendering search results in a browser

The package includes a web.js module that hooks into a button on a page & draws an input field when a user clicks on the button.

import * as nfts from './web.js'

let conf = {
    "toggle_button": "#my-button",
    "container": "#my-div",
    "server": "http://localhost:3000",
    "debounce": 200
}

new nfts.Frame(conf)

Frame constructor supports 3 additional arguments, each of which is a function for calculating an href for:

  1. blog posts

     function post_href(entry)

    where entry is an object returned by nfts-server.

  2. author pages

     function author_href(name)

    where name is an author name.

  3. tag pages

     function tag_href(name)

    where name is a tag name.

You can omit all 3, but then web.js won't render links to what nfts-server has returned.

Jekyll integration example

To show how a real static blog can be augmented w/ FTS, we'll use the repo for the old RoR blog:

$ git clone https://github.com/rails/weblog.git
$ cd weblog
# use Ruby 3.1.x to run the following 2 commands,
# possibly removing Gemfile.lock first
$ bundle install
$ jekyll s --no-watch

Open http://127.0.0.1:4000 to browse the blog.

In another terminal:

$ cd weblog
$ nfts-add -o db.sqlite3 -s _posts/ _posts/*
$ nfts-server db.sqlite3

To test the server:

$ curl 'http://localhost:3000/?q=omg'

This should return an array of snippets.

Next:

  1. Edit _includes/navigation.html to add a link for invoking a search dialog:

     <li><a id="my-search" href="#">Search</a></li>
  2. Copy web.js file from the package to weblog dir, & rename it to nfts.js.

  3. Add to _config.yml:

    nfts:
      toggle_button: '#my-search'
      container: 'main > article'
      server: http://localhost:3000
  4. Add to _includes/navigation.html:

    import * as nfts from '/nfts.js'
    new nfts.Frame(JSON.parse('{{site.nfts | jsonify }}'),
        entry => { // post
            let date = entry.date ? entry.date*1000 : null
            let prefix = nfts.date_fmt(date || entry.file.slice(0,10))
            let basename = entry.file.slice(10+1).replace(/\.[^.]+$/, '')
            return '{{site.url}}' + '/' + prefix + '/' + basename
        },
        null,
        null)

The nfts integration is complete. Restart Jekyll, make sure it has finished regenerating the site, & refresh the blog page in the browser. Then click "Search" & type "omg" (you don't need to press Enter).

License

MIT