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

@formata/limitr

v0.5.24

Published

**Stop hardcoding your pricing. Treat it like config.**

Downloads

1,163

Readme

Limitr

Stop hardcoding your pricing. Treat it like config.

// Before: Pricing logic scattered everywhere
if (user.plan === 'free' && user.seats >= 1) {
  throw new Error('Upgrade to add more seats');
}

// After: One source of truth
if (await policy.increment('user_123', 'seats')) {
  // Add the seat
}

Limitr is an open-source pricing engine that moves your limits, quotas, and feature gates out of application code and into a declarative policy document.

Powered by WebAssembly for deterministic, portable enforcement across Node.js, browsers, Deno, and Bun.

The Problem

Your pricing logic is everywhere:

  • Hardcoded in route handlers
  • Duplicated across services
  • Impossible to change without deploying
  • Breaks when product changes the free tier

Changing "free tier gets 1 seat → 3 seats" shouldn't require a code change.

How It Works

1. Define your pricing once

policy:
  credits:
    seat:
      label: Seat
  plans:
    free:
      entitlements:
        seats:
          limit:
            credit: seat
            value: 1
    pro:
      entitlements:
        seats:
          limit:
            credit: seat
            value: 10

2. Enforce everywhere

const policy = await Limitr.new(policyDoc);

// Seat limits
await policy.allow('user_123', 'seats', 1);

// Usage limits
await policy.allow('user_456', 'ai_tokens', 4200);

// Feature gates
await policy.allow('user_789', 'advanced_analytics');

3. Change pricing without redeploying Update the policy document. That's it.

Install

npm install @formata/limitr

Initialization (Browser Only)

Limitr uses Stof for policy enforcement, which compiles to WebAssembly. Browser apps need to initialize WASM once before use. Node.js, Deno, and Bun handle this automatically—skip this step.

// Vite
import { initStof } from '@formata/stof';
import stofWasm from '@formata/stof/wasm?url';
await initStof(stofWasm);

// Other bundlers (with WASM plugin)
import { initStof } from '@formata/stof';
import stofWasm from '@formata/stof/wasm';
await initStof(await stofWasm());

Quick Start

import { Limitr } from '@formata/limitr';

const policy = await Limitr.new(`
policy:
  credits:
    seat:
      label: Seat
  plans:
    free:
      entitlements:
        seats:
          limit:
            credit: seat
            value: 1
            increment: 1
    pro:
      entitlements:
        seats:
          limit:
            credit: seat
            value: 10
            increment: 1
`, 'yaml');

await policy.createCustomer('user_123', 'free');

await policy.increment('user_123', 'seats'); // true (increment -> shorthand for allow(..) with limit's "increment" value)
await policy.increment('user_123', 'seats'); // false (limit hit)

When To Use This

  • ✅ You have seat-based, usage-based, or hybrid pricing
  • ✅ Your pricing changes more than once a quarter
  • ✅ You support self-hosted deployments
  • ✅ You're building an AI product with token limits
  • ✅ You're tired of pricing logic in 47 different files
  • ✅ Easy to adopt incrementally, wrap existing checks with policy.allow() one at a time

Local vs Cloud

Local (Open Source)

Runs entirely in your app. No external calls. Perfect for self-hosted.

const policy = await Limitr.new(policyDoc);

Cloud (Managed + Stripe)

Hosted version with Stripe integration, customer management, dashboard, and analytics.

const policy = await Limitr.cloud({
  token: 'limitr_...'
});
  • Change pricing in minutes without redeploys
  • Built-in UI for pricing tables, plan selection, invoices
  • Automatic sync with Stripe
  • Analytics dashboards

Learn more about Limitr Cloud →

How It's Different

Stripe knows: "User paid for Pro plan" Limitr enforces: "User can create 10 seats, use 1M tokens, and export PDFs"

Most apps:

  1. Check limits in code → if (user.plan === 'free')
  2. Take action
  3. Send usage to billing system

With Limitr:

  1. Check policy → await policy.allow('user', 'action')
  2. Take action
  3. Usage tracked automatically (Cloud) or synced on your schedule (Local)

Real-World Examples

Seat-based SaaS:

if (await policy.increment('org_123', 'seats')) {
  await db.addUserToOrg(userId, orgId);
}

AI product with token limits:

if (await policy.allow('user_456', 'tokens', estimatedTokens)) {
  const response = await callLLM(prompt);
  // Usage recorded, synced in background
}

Feature gating:

const canExport = await policy.allow('user_789', 'pdf_export');
if (!canExport) {
  return { error: 'Upgrade to export PDFs' };
}

Why Policies Are Better Than Code

Update your free tier limit at 3pm on Friday. All users see the new limit and it's enforced instantly. No deploy, no invalidation, no coordination.

Code:

  • Scattered across files
  • Requires deploys to change
  • Hard to audit
  • Breaks with typos

Policy:

  • Single source of truth
  • Change without deploying
  • Human-readable by customers and auditors
  • Type-safe (compiled to WebAssembly)

Tech Details

  • Written in Stof (compiles to WebAssembly)
  • Microsecond enforcement (no network calls)
  • Runs in Node.js, browsers, Deno, Bun
  • Deterministic (same input = same output)
  • No external dependencies for local mode
  • Offline-first (no API calls required)

Documentation

Contributing

Issues & PRs: GitHub
Questions: Discord
Contact: [email protected]

License

Apache 2.0