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

tsense

v0.2.1

Published

Opinionated, fully typed typesense client

Readme

TSense

Fully-typed Typesense client powered by Arktype.

Define your schema once. Get type-safe search, filtering, and automatic filter UIs — all from the same source of truth.

bun add tsense arktype

Define a collection

import { type } from "arktype";
import { TSense } from "tsense";

const Users = new TSense({
  name: "users",
  schema: type({
    "id?": "string",
    name: type("string").configure({ sort: true, index: true }),
    age: type("number.integer").configure({ type: "int32", sort: true }),
    company: type
      .enumerated("netflix", "google", "apple")
      .configure({ facet: true }),
    active: type("boolean").configure({ facet: true }),
    "joined_at?": "Date",
  }),
  connection: {
    host: "127.0.0.1",
    port: 8108,
    protocol: "http",
    apiKey: "xyz123",
  },
  defaultSearchField: "name",
});

Search with typed filters

Operators are restricted per field type — the compiler catches invalid combinations.

await Users.search({
  filter: {
    age: { gte: 18, lte: 40 },
    company: ["netflix", "google"],
    name: { not: "admin" },
  },
});

Paginated lists

const page1 = await Users.searchList({
  sortBy: "age:asc",
  filter: { active: true },
  limit: 20,
});

const page2 = await Users.searchList({
  sortBy: "age:asc",
  filter: { active: true },
  limit: 20,
  cursor: page1.nextCursor!,
});

Count

const total = await Users.count();
const active = await Users.count({ active: true });

Multi-tenancy with scoped

scoped() returns a narrowed instance where a base filter is merged into every operation. The caller cannot override it.

const myUsers = Users.scoped({ owner_id: currentUser.id });

await myUsers.search({ filter: { active: true } });
// filter_by = "active:=true && owner_id:=`user-1`"

await myUsers.count({ active: true });
await myUsers.deleteMany({ active: false });

Build filter UIs from the schema

Declare which fields are filterable. tsense introspects the arktype schema, detects enums, and produces a descriptor that travels to the frontend as JSON.

import { createFilterBuilder } from "tsense/filters";

const filters = createFilterBuilder(Users, {
  name: { label: "Name" },
  age: {
    label: "Age",
    presets: { "Over 18": { age: { gte: 18 } } },
  },
  company: {
    label: "Company",
    labels: { netflix: "Netflix", google: "Google", apple: "Apple" },
  },
  active: { label: "Active" },
  joined_at: { label: "Joined At" },
});

const descriptor = filters.describe();

Render it

Drop the descriptor into the React component. The user picks columns, conditions, and values. You get a typed FilterFor<User> back.

import { FilterBuilder } from "tsense/react";

<FilterBuilder descriptor={descriptor} onChange={(filter) => search(filter)} />;

Every slot is replaceable via render props — or use the headless useFilterBuilder hook for full control.

Wire it end-to-end

Backend validates input with the filter builder schema, scopes results by user, and exposes the descriptor. Frontend renders the builder and fires queries.

// backend
const filters = createFilterBuilder(Users, config);

const authed = base.use(({ context, next }) => {
  if (!context.user) throw new ORPCError("UNAUTHORIZED");
  return next({ context: { user: context.user } });
});

const router = base.router({
  search: authed
    .input(filters.schema())
    .handler(({ input, context }) =>
      Users.scoped({ owner_id: context.user.id }).search(input),
    ),
});
// frontend
import { describe } from "./api/describe" with { type: "macro" };

const descriptor = describe();
const [filter, setFilter] = useState<typeof descriptor.infer>({});

<FilterBuilder descriptor={descriptor} onChange={setFilter} />;

const { data: results } = useQuery(api.search, { filter });

The descriptor is inlined at build time via Bun macros — no RPC call needed.

A working example with docker-compose, seed data, and a full UI lives in examples/.