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

@newgentdigital/auto-param-astro

v1.3.0

Published

Automatically add your parameters to external links and URLs during build time with Astro.

Downloads

184

Readme

Repository banner for @newgentdigital/auto-param-astro

@newgentdigital/auto-param-astro

Astro integration that adds configured query parameters to external links at build time.

Install

bun add @newgentdigital/auto-param-astro
# or
npm i @newgentdigital/auto-param-astro

Usage

// astro.config.mjs
import autoParamAstro from "@newgentdigital/auto-param-astro";
import { defineConfig } from "astro/config";

export default defineConfig({
  integrations: [
    autoParamAstro({
      params: {
        utm_source: "newsletter",
        utm_medium: "email",
      },
      paramMode: "replace",
      exemptDataAttributes: ["data-auto-param-exempt"],
      exemptDomains: ["example.com", "*.github.com"],
    }),
  ],
});

How the integration works

  • Runs during the astro:build:done hook.
  • Walks the build output directory and rewrites *.html files.
  • Updates <a href="https://..."> links (and protocol-relative //...) by inserting/updating params.
  • Skips links that:
    • have any configured exemptDataAttributes present on the <a> tag
    • point to a host in exemptDomains (exact match or subdomain match; also supports leading-wildcard *.example.com)

Options

Required settings

  • params: Record<string, string | number | boolean>

Optional settings

  • paramMode: "preserve" | "override" | "replace"
    • Default: "preserve"
    • preserve (a): keep existing URL params, only add missing configured params
    • override (b): keep existing URL params, but overwrite values for configured keys
    • replace (c): remove all existing URL params and add only configured params
  • exemptDataAttributes: string[]
    • Default: ["data-auto-param-exempt"]
  • exemptDomains: string[]
    • Default: []

Explanation of paramMode

Assume you have the following integration config:

// astro.config.mjs
autoParamAstro({
  params: {
    utm_source: "newsletter",
    utm_medium: "email",
    utm_term: "winter",
    ref: true,
    v: 2,
  },
});

... and this incoming link in your code:

https://example.com/pricing?utm_source=twitter&utm_medium=social&utm_medium=ads&utm_campaign=sale#faq

What result the integration generates depends on your paramMode:

  • preserve (default)

    • Keeps existing values for any configured parameters that already exist.
    • Only adds configured parameters that are missing.
    • Result: https://example.com/pricing?utm_source=twitter&utm_medium=social&utm_medium=ads&utm_campaign=sale&utm_term=winter&ref=true&v=2#faq
  • override

    • Overwrites configured parameters (and collapses duplicates for those parameters to a single value).
    • Leaves non-configured parameters (like utm_campaign) alone.
    • Result: https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_campaign=sale&utm_term=winter&ref=true&v=2#faq
  • replace

    • Drops all existing query parameters, then adds only configured ones.
    • Keeps the path and hash.
    • Result: https://example.com/pricing?utm_source=newsletter&utm_medium=email&utm_term=winter&ref=true&v=2#faq

Exempt a single link

A link with the default attribute data-auto-param-exempt or one of the configured exemptDataAttributes will prevent the integration from updating the href for that link.

<a href="https://example.com" data-auto-param-exempt>
  This link will not be modified.
</a>