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

affiliate-link-manager

v0.1.0

Published

A lightweight utility for centralizing and resolving affiliate links.

Readme

affiliate-link-manager

A lightweight utility for centralizing and resolving affiliate links.

This project provides a simple way to define, retrieve, and manage affiliate links from a single source of truth. It is designed for publishers, content sites, newsletters, and applications that need consistent affiliate link handling without scattering raw URLs across templates, pages, or code.

It can be used as both a practical utility and a reference pattern for link management.

Why this project exists

Affiliate links often end up spread across content files, templates, scripts, and CMS fields.

That creates avoidable problems. Links become hard to update, harder to audit, and easy to break. A program change, URL update, or tracking parameter adjustment can require editing content in many places.

Without a centralized approach:

  • link maintenance becomes repetitive.
  • mistakes are harder to detect.
  • reporting and auditing are harder to perform.
  • content becomes tightly coupled to affiliate URLs.

This project introduces a small management layer that keeps affiliate link definitions in one place and makes them easy to resolve consistently.

Mental model

This package sits between your content and the final affiliate URL:

Content or app -> link key -> affiliate link manager -> resolved URL

Instead of hardcoding affiliate links everywhere, your system refers to stable keys and lets the manager return the correct destination.

What is included

  • Link registry creation.
  • Link lookup by key.
  • Safe updates to existing entries.
  • Category and tag filtering.
  • Optional active/inactive status handling.
  • Redirect-friendly URL resolution helpers.
  • Example usage demonstrating integration.
  • Test coverage for core link management behavior.

Install

npm install affiliate-link-manager

Example

import {
  createAffiliateRegistry,
  getAffiliateLink,
  setAffiliateLink,
  resolveAffiliateUrl
} from "affiliate-link-manager";

const registry = createAffiliateRegistry([
  {
    key: "booking",
    name: "Booking.com",
    url: "https://example.com/booking-affiliate",
    category: "travel",
    tags: ["hotels", "accommodation"],
    active: true
  }
]);

setAffiliateLink(registry, "worldnomads", {
  name: "World Nomads",
  url: "https://example.com/worldnomads-affiliate",
  category: "insurance",
  tags: ["travel", "insurance"],
  active: true
});

const booking = getAffiliateLink(registry, "booking");
const bookingUrl = resolveAffiliateUrl(registry, "booking");

console.log(booking.name);
console.log(bookingUrl);

Link entry shape

Each link entry follows a consistent structure:

{
  "key": "booking",
  "name": "Booking.com",
  "url": "https://example.com/booking-affiliate",
  "category": "travel",
  "tags": ["hotels", "accommodation"],
  "active": true,
  "meta": {
    "createdAt": "2026-03-25T00:00:00.000Z",
    "updatedAt": "2026-03-25T00:00:00.000Z"
  }
}

Core operations

The package is intentionally simple. It focuses on a few essential operations:

  • create a registry.
  • add or update links.
  • get a link by key.
  • resolve a final URL by key.
  • list links by category or tag.
  • disable a link without deleting it.

This keeps the interface small and easy to adopt.

Why this matters

Centralizing affiliate links improves consistency across content systems.

When links are stored and resolved from one place, it becomes easier to update programs, rotate links, audit partner usage, and reduce broken links across sites or newsletters.

It also helps separate editorial content from monetization infrastructure. That makes systems cleaner and easier to maintain over time.

Design Principles

This project is intentionally minimal.

It defines a small link management layer rather than a full affiliate platform. The goal is to provide a stable and understandable utility that can be used across websites, scripts, and publishing workflows.

The design emphasizes:

  • Simplicity over abstraction.
  • Centralization over duplication.
  • Consistency over ad hoc editing.
  • Maintainability over feature sprawl.

Non-Goals

This project does not attempt to:

  • provide analytics dashboards.
  • replace an affiliate network platform.
  • manage payouts or reporting.
  • enforce redirect infrastructure.

It focuses only on defining and resolving affiliate links in a consistent way.

Roadmap

This project is designed as a foundation for broader affiliate workflow tooling. Future extensions may include:

  • JSON import and export helpers.
  • CSV sync utilities.
  • redirect map generation.
  • validation rules for duplicate URLs or missing fields.
  • click logging hooks.
  • static site integration helpers.

Example use cases

This utility is useful in contexts such as:

  • content sites with recurring affiliate references.
  • newsletters that reuse the same partner links.
  • static sites that want central link control.
  • scripts that generate pages or product roundups.
  • publishing systems that separate content from monetization logic.

License

MIT