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

@b87/tanstack-tw-table

v0.1.3

Published

TanStack Table with shadcn/ui, server-side support, views, i18n, and framework-agnostic routing

Readme

@b87/tanstack-tw-table

A batteries-included data table component built with TanStack React Table, featuring server-side operations, filtering, sorting, pagination, view management, and URL synchronization.

Features

  • 🔍 Advanced Filtering - 20+ filter operators with server-side support
  • 📊 Server-Side Operations - Sorting, filtering, and pagination with QueryBuilder
  • 💾 View Management - Save and load custom table configurations
  • 🔗 URL Synchronization - Deep linking support for shareable table states
  • 🔧 Type-Safe - Full TypeScript support with auto-detected column metadata
  • 🎨 shadcn/ui Ready - Built with Tailwind CSS and shadcn/ui components
  • 🔌 Framework Agnostic - Works with Next.js, React Router, or standalone

Quick Start

Installation

npm install @b87/tanstack-tw-table @tanstack/react-table @tanstack/react-virtual

Import CSS in your root stylesheet:

@import "@b87/tanstack-tw-table/theme-v3.css"; /* Tailwind v3 */
/* or */
@import "@b87/tanstack-tw-table/theme.css"; /* Tailwind v4 */

See the Setup Guide for complete configuration.

Client-Side Example

import { DataTable } from "@b87/tanstack-tw-table";
import { createNextRouter } from "@b87/tanstack-tw-table/routing";
import type { ColumnDef } from "@tanstack/react-table";

const columns: ColumnDef<User>[] = [
  {
    accessorKey: "name",
    header: "Name",
    meta: { searchable: true }, // Auto-detected
  },
  {
    accessorKey: "status",
    header: "Status",
    meta: {
      filterable: {
        options: [
          { label: "Active", value: "active" },
          { label: "Inactive", value: "inactive" },
        ],
      },
    },
  },
];

export function UsersTable() {
  const router = createNextRouter();

  return (
    <DataTable
      data={users}
      columns={columns}
      pageCount={1}
      tableId="users-table"
      router={router}
      features={{
        viewManagement: true,
        urlSync: true,
      }}
      server={{
        mode: "client", // Client-side operations
      }}
    />
  );
}

Server-Side Example

"use client";

import { useState, useCallback, useEffect } from "react";
import type { ColumnDef, ColumnFiltersState, SortingState, PaginationState } from "@tanstack/react-table";
import { DataTableCore, useDataTable, useServerQuery } from "@b87/tanstack-tw-table";
import { extractSearchableColumns, extractFilterableColumns } from "@b87/tanstack-tw-table";

export function ServerSideTable() {
  const [users, setUsers] = useState<User[]>([]);
  const [pageCount, setPageCount] = useState(0);

  const { buildQuery, processServerResponse } = useServerQuery<User>({
    searchableColumns: ["name", "email"],
  });

  const fetchData = useCallback(async (tableState: {
    columnFilters?: ColumnFiltersState;
    sorting?: SortingState;
    globalFilter?: string;
    pagination?: PaginationState;
  }) => {
    const queryParams = buildQuery(
      tableState.columnFilters || [],
      tableState.sorting || [],
      tableState.globalFilter,
      tableState.pagination
    );

    const response = await fetch(`/api/users?${queryParams.toString()}`);
    const result = await response.json();

    processServerResponse(result);
    setUsers(result.data);
    setPageCount(result.pagination?.totalPages || 1);
  }, [buildQuery, processServerResponse]);

  const { table } = useDataTable({
    data: users,
    columns,
    pageCount,
    tableId: "users-server",
    manualPagination: true,
    manualSorting: true,
    manualFiltering: true,
    urlSync: false,
    onSortingChange: async ({ sorting, state, resetPagination }) => {
      await fetchData({
        ...state,
        sorting,
        pagination: resetPagination ? { pageIndex: 0, pageSize: state.pagination.pageSize } : state.pagination,
      });
    },
    onFilterChange: async ({ columnFilters, globalFilter, state }) => {
      await fetchData({ ...state, columnFilters, globalFilter });
    },
    onPaginationChange: async ({ pagination, state }) => {
      await fetchData({ ...state, pagination });
    },
  });

  useEffect(() => {
    fetchData({ columnFilters: [], sorting: [], globalFilter: "", pagination: { pageIndex: 0, pageSize: 10 } });
  }, []);

  return (
    <DataTableCore
      table={table}
      columns={columns}
      searchableColumns={extractSearchableColumns(columns)}
      filterableColumns={extractFilterableColumns(columns)}
    />
  );
}

Documentation

Key Concepts

  • Column Metadata Auto-Detection - Define searchable and filterable in column.meta
  • State Injection Pattern - Server callbacks receive complete table state
  • QueryBuilder - Type-safe query building with 20+ filter operators
  • URL Sync - Optional deep linking with router adapters (Next.js, React Router)
  • View Management - Save/load table configurations with localStorage

Contributing

See the Contributing Guide (if available) or check the source code for examples.

License

MIT License