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

@soulreaper67/table-sort-filter

v0.1.0

Published

Sort, filter and paginate any HTML table. Zero dependency, < 3kb gzip.

Readme

table-sort-filter.js

Sort, filter and paginate any HTML table. 2 lines of code. Zero dependency, < 3kb gzip.

npm version license gzip size

The problem: Every project has tables that need sorting, filtering and pagination — and every solution is either too heavy (DataTables, AG Grid) or incomplete (sort-only, filter-only).

The solution: 2 lines of code.


Install

npm install table-sort-filter

Or via CDN:

<script type="module">
  import TableSF from 'https://cdn.jsdelivr.net/npm/table-sort-filter/src/table-sort-filter.js'
</script>

Quick start

<table id="my-table">
  <thead>
    <tr><th>Name</th><th>Age</th><th>City</th></tr>
  </thead>
  <tbody>
    <tr><td>Alice</td><td>28</td><td>Paris</td></tr>
    <tr><td>Bob</td><td>34</td><td>Lyon</td></tr>
  </tbody>
</table>

<script type="module">
  import TableSF from 'table-sort-filter'
  TableSF.init('#my-table')
</script>

That's it. Your table now has:

  • Clickable headers to sort columns (text and numeric)
  • Search input to filter rows instantly
  • Pagination (optional)
  • No results message when nothing matches

Options

TableSF.init('#my-table', {
  sortable:    true,              // clickable column headers (default: true)
  filterable:  true,              // search input above table (default: true)
  paginate:    10,                // rows per page, 0 = disabled (default: 0)
  searchCols:  [0, 1],            // columns to search (default: all)
  placeholder: 'Search...',      // search input placeholder
  onSort:   (col, dir) => {},    // callback after sort
  onFilter: (query) => {},       // callback after filter
  onPage:   (page) => {},        // callback after page change
})

Methods

// Remove table-sort-filter from a table
TableSF.destroy('#my-table')

// Reset sort, filter and page to defaults
TableSF.reset('#my-table')

// Get all active tables and their state
TableSF.getAll()
// → [{ table, state: { sortCol, sortDir, query, page }, opts }]

Framework usage

React

import TableSF from 'table-sort-filter'
import { useEffect } from 'react'

function DataTable() {
  useEffect(() => {
    TableSF.init('#data-table', { paginate: 10 })
    return () => TableSF.destroy('#data-table')
  }, [])

  return (
    <table id="data-table">...</table>
  )
}

Vue

<script setup>
import TableSF from 'table-sort-filter'
import { onMounted, onUnmounted } from 'vue'

onMounted(() => TableSF.init('#my-table'))
onUnmounted(() => TableSF.destroy('#my-table'))
</script>

Comparison

| | table-sort-filter | DataTables | tablesort | tablefilter | |---|---|---|---|---| | Sort | ✅ | ✅ | ✅ | ❌ | | Filter | ✅ | ✅ | ❌ | ✅ | | Paginate | ✅ | ✅ | ❌ | ❌ | | Zero dep | ✅ | ❌ jQuery | ✅ | ❌ | | ES module | ✅ | ❌ | ❌ | ❌ | | Size | ~3kb | 500kb+ | 2kb | 400kb+ |


Browser support

| Chrome | Firefox | Safari | Edge | |---|---|---|---| | ✅ 61+ | ✅ 60+ | ✅ 10.1+ | ✅ 16+ |


License

MIT © TwinMi Studio