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

next-dynamic-sitemap

v1.1.0

Published

A lightweight, zero-touch sitemap generator for any nextjs project

Readme

🗺️ next-dynamic-sitemap

A zero-config dynamic sitemap generator for Next.js apps using the App Router or Pages Router — with full support for generateStaticParams and getStaticPaths. Automatically includes lastModified data from your static param functions.


✨ Features

  • ✅ Works with both App Router (generateStaticParams) and Pages Router (getStaticPaths)
  • 🕰️ Supports custom lastModified dates per route
  • 🗂️ Outputs to public/sitemap.xml automatically
  • 🔧 Configurable via .env (via dotenv-flow)
  • 🧠 Smart enough to skip dynamic routes without params

📦 Installation

npm install next-dynamic-sitemap

🚀 Usage

You can invoke the generator manually:

npx sitemap-gen

Or add it to your Next.js build step:

{
  "scripts": {
    "build": "sitemap-gen && next build"
  }
}

🛠️ Example: App Router

// app/projects/[slug]/page.tsx

export async function generateStaticParams() {
  const projects = await getAllProjects();
  return projects.map((project) => ({
    slug: project.slug,
    lastModified: new Date(project.updatedAt),
  }));
}

📄 Output

The sitemap will be generated at:

public/sitemap.xml

🌐 Required Environment Variable

Set the base URL of your site via an env file (.env, .env.local, etc.):

SITEMAP_GEN_BASE_URL=https://example.com

This is used to fully qualify URLs in the sitemap.


CLI Options

Run npx sitemap-gen --help to see available options:

Usage: sitemap-gen [options]

Options:
-c, --config <path>  Path to a custom config file (e.g. sitemap-gen.config.js)
-h, --help           Display CLI usage help

Configuration

You can optionally supply a configuration, if you need to overload default behaviors such as esbuild options.

Example: sitemap-gen.config.js

/** @type {import('sitemap-gen').Config} */

const config = {
  esbuild: {
    loader: {
      ".css": "css",
    },
    // ... any other esbuild options
  },
  exclude: [
    "/my-secret-path",
    /^\/my-secret-prefix\//,
    // ... any other string or regex for exclusion
  ],
};

export default config;

Usage

Pass the config to the CLI using -c or --config:

npx sitemap-gen -c ./sitemap-gen.config.js

If no config is provided, sitemap-gen will use sensible defaults.


🧪 Works With

  • ✅ Static Routes
  • ✅ Dynamic Routes with generateStaticParams or getStaticPaths
  • ✅ Catch-all / Optional Catch-all routes (as long as they’re statically generated)
  • ⚠️ Does not include server-only or client-only routes that aren’t statically known at build time

📘 License

ISC License


💡 Tips

  • Want custom priority, changefreq, or more? That’s coming soon — or open an issue/PR!

🐛 Bugs? Ideas?

Open an issue or send a PR — contributions welcome!