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

@trevosdk/node

v0.1.1

Published

Trevo server SDK — deterministic variant assignment and event tracking for Node, Bun, Deno and edge runtimes

Downloads

218

Readme

@trevosdk/node

Run experiments outside the browser, and record conversions an ad blocker can never touch.

npm install @trevosdk/node

Install this before you run a single backend experiment

The cheapest reason to adopt this is not backend experimentation — it is that a subscription_started fired from your Stripe webhook is never lost to an ad blocker, a closed tab, or a failed beacon on unload. Client-side conversion tracking loses somewhere between a few and a few tens of percent of events that way, and those losses are not random: they correlate with browser, region, and privacy tooling.

Moving your money events server-side improves the statistics for every experiment you already run in the browser, before you ever call getVariant from a backend.

Quick start

import { createClient } from '@trevosdk/node';

const trevo = createClient({ secretKey: process.env.TREVO_SECRET_KEY });

// Assignment needs config. Await this once during startup, or every request in
// the first moments after a deploy falls back to control.
await trevo.ready();

const variant = trevo.getVariant('pricing-algo-v2', {
  userId: req.user?.id,
  anonymousId: req.cookies.trevo_id,
});

trevo.track('subscription_started', { userId, anonymousId }, { plan: 'pro' });

The key is a server key (tsk_secret_…), created under Settings → API keys with platform Server. It is shown once. Never use it in client code.

The rule that keeps client and server agreeing

Bucket with the same identity the browser is using at that moment: userId when the user is identified, otherwise the trevo_id cookie.

Assignment is deterministic on that identity. Pass something else — an internal account id, an email, a fresh uuid — and the same person gets variant A in the browser and variant B from your backend.

getVariant returns "control" and records nothing when neither id is present. That is deliberate — an unbucketed user is better than a wrongly bucketed one.

Identity linking

Trevo links an anonymous journey to a user the first time it sees an event carrying both ids. A webhook, a cron job, or a queue worker has no cookie to read, so its events arrive with a bare userId and that user's pre-login browsing is never stitched to their conversion.

When you cannot supply both ids on an event, state the link directly:

await trevo.alias(req.cookies.trevo_id, user.id);

An anonymous id belongs to one user. Re-pointing one at a different user is rejected rather than silently rewriting the link.

Runtimes

Web-standard APIs only (fetch, AbortSignal, timers), so Node 18+, Bun, Deno, Cloudflare Workers and Vercel edge all work with no adapter.

On serverless, create the client at module scope and await trevo.flush() before returning — the runtime may freeze the moment your handler resolves, taking queued events with it. On Cloudflare Workers, prefer ctx.waitUntil(trevo.flush()).

Documentation

Full reference, framework recipes (Express, Fastify, NestJS, serverless) and the identity model: https://docs.trevosdk.com

License

MIT