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

@tribute-tg/better-auth

v2.1.9

Published

Tribute integration for better-auth

Readme

@tribute-tg/better-auth

A Better Auth plugin for integrating Tribute payments and subscriptions into your authentication flow.

Features

  • Checkout Integration
  • Handle Tribute Webhooks securely with signature verification

Installation

npm i better-auth @tribute-sh/better-auth @tribute-tg/sdk

Preparation

Authorization token can be obtained from a network request in the web version of Telegram while using the Tribute mini-app. See Authorization header (in the request with tribute.tg host) and copy value after TgAuth prefix.

API key can be obtained from the Tribute Developers Settings page: https://wiki.tribute.tg/for-content-creators/api-documentation#how-to-get-an-api-key

# .env
TG_AUTH_TOKEN=...
TRIBUTE_API_KEY=...

Configuring BetterAuth Server

The Tribute plugin comes with a handful additional plugins which adds functionality to your stack.

  • Checkout - Enables a seamless checkout integration
  • Webhooks - Listen for relevant Tribute webhooks
import { betterAuth } from "better-auth";
import { tribute } from "@tribute-tg/better-auth";
import { Tribute } from "@tribute-tg/sdk";

const tributeClient = new Tribute({ token: process.env.TG_AUTH_TOKEN, apiKey: process.env.TRIBUTE_API_KEY });

const auth = betterAuth({
  // ... Better Auth config
  plugins: [
    tribute({
      tributeClient,
      subscriptions: [
        {
          subscriptionId: 123456, // ID of Subscription from Tribute
          slug: "pro" // Custom slug for easy reference in Checkout URL, e.g. /checkout/pro
        }
      ],
      onNewSubscription: (payload) => // Triggered when subscription was created
      onCancelledSubscription: (payload) => // Triggered when subscription was canceled
      ...  // Other webhook handlers
      onEvent: (event) => // Catch-all for all events
    })
  ]
});

Configuring BetterAuth Client

You will be using the BetterAuth Client to interact with the Tribute functionalities.

import { createAuthClient } from 'better-auth/react';
import { tributeClient } from '@tribute-tg/better-auth';

// This is all that is needed
// All Tribute plugins, etc. should be attached to the server-side BetterAuth config
export const authClient = createAuthClient({
  plugins: [tributeClient()],
});

Configuration Options

import { betterAuth } from 'better-auth';
import { tribute, checkout, webhooks } from '@tribute-tg/better-auth';
import { Tribute } from '@tribute-tg/sdk';

const tributeClient = new Tribute({ token: process.env.TG_AUTH_TOKEN, apiKey: process.env.TRIBUTE_API_KEY });

const auth = betterAuth({
  // ... Better Auth config
  plugins: [
    tribute({
      tributeClient,
      // This is where you add Tribute options
    }),
  ],
});

Required Options

  • tributeClient: Tribute SDK client instance

Checkout

To support checkouts in your app, simply pass the Checkout to the use-property.

import { tribute } from "@tribute-tg/better-auth";

const auth = betterAuth({
  // ... Better Auth config
  plugins: [
    tribute({
      ...
      // Optional field - will make it possible to pass a slug to checkout instead of Subscription ID
      subscriptions: [ { subscriptionId: 123456, slug: "pro" } ],
    })
  ]
});

When checkouts are enabled, you're able to initialize Checkout Sessions using the checkout-method on the BetterAuth Client. This will redirect the user to the Subscription Checkout.

await authClient.checkout({
  // Any Tribute Subscription ID can be passed here
  subscriptionId: 123456,
  // Or, if you setup "subscriptions" in the Checkout Config, you can pass the slug
  slug: 'pro',
});

Webhooks

The Webhooks can be used to capture incoming events from your monetized Telegram channels.

import { tribute } from "@tribute-tg/better-auth";

const auth = betterAuth({
  // ... Better Auth config
  plugins: [
    tribute({
      ...
      onNewSubscription: (payload) => // Triggered when subscription was created
      onCancelledSubscription: (payload) => // Triggered when subscription was canceled
      ...  // Other webhook handlers
      onEvent: (event) => // Catch-all for all events
    })
  ]
});

Configure a Webhook endpoint in your Tribute Developers Settings page. Webhook endpoint is configured at /tribute/webhooks.

Add the API key to your environment.

# .env
TRIBUTE_API_KEY=...

The plugin supports handlers for all Tribute webhook events:

  • onEvent - Catch-all handler for any incoming Webhook event
  • onNewSubscription - Triggered when a subscription is created
  • onCancelledSubscription - Triggered when a subscription is updated