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-runtime-sitemap

v1.0.10

Published

Generates a sitemap for nextjs apps at runtime, using a crawl of the local filesystem

Readme

🛰️ next-runtime-sitemap

Generate sitemaps at runtime for Next.js projects, based on your actual deployed filesystem.

npm version
GitHub issues


✨ Features

  • 🧠 Runtime sitemap generation — no need for build-time crawling or prerendering.
  • 📂 Filesystem-aware — inspects your deployed .next directory to find generated pages.
  • 🔁 Works with revalidation — dynamic routes are supported via force-static + revalidate.
  • 🪶 Now supports Pages Router — your sitemap can now include pages from both app/ and pages/ directories.

🚧 Requirements

⚠️ Not compatible with serverless platforms like Vercel
Serverless functions run in isolated environments and only have access to files that are statically imported.
Since this package inspects the deployed filesystem at runtime, it must run in a persistent environment (e.g., custom Node.js server, Docker, or self-hosted deployment).

  • ✅ Sitemap route must be hosted via the App Router (app/ directory).
  • ✅ Supports both App Router and Pages Router pages in the generated sitemap.
  • ✅ You must enable force-static + revalidate on dynamic routes for them to persist to the filesystem.
  • ✅ Static routes are automatically captured.
  • ❌ Fully dynamic (e.g., force-dynamic) routes are not included—they don’t emit files.

🛠️ Installation

npm install next-runtime-sitemap

📦 Usage

Add a route file to your Next.js app at:

app/sitemaps/[sitemap]/route.ts

Inside that file:

import { generateAppRouterSitemap } from "next-runtime-sitemap/dist/app";

module.exports = generateAppRouterSitemap();

🔄 This route must live inside the App Router, but it can generate a sitemap that includes both App and Pages Router pages.


🌍 Configuration

Base URL

Internationalization (i18n)

If your project uses Next.js internationalized routing, the sitemap will now automatically include both:

  • All localized routes (e.g., mysite.com/en/about)
  • Their de-localized equivalents (e.g., mysite.com/about), mapped from the default locale

To enable this behavior, pass your default locale explicitly when generating the sitemap:

import { generateAppRouterSitemap } from "next-runtime-sitemap/dist/app";

module.exports = generateAppRouterSitemap({ defaultLocale: "en" });

You must provide a SITEMAP_GEN_BASE_URL environment variable.

It’s used to generate absolute URLs in your sitemap.

For example, in .env.local:

SITEMAP_GEN_BASE_URL=https://your-domain.com

This package uses dotenv-workflow, so it will respect .env, .env.local, .env.development, etc.


🔗 Related

This package depends on next-dynamic-sitemap internally for utility functions, but:

  • next-dynamic-sitemap is for build-time sitemap generation.
  • next-runtime-sitemap is for runtime sitemap generation.

Use the right one depending on your architecture.


📄 Example Output

Visit /sitemaps/sitemap.xml in your browser, or curl it:

curl https://your-domain.com/sitemaps/sitemap.xml

You’ll get a standard XML sitemap that reflects your currently built static and dynamic (with revalidation) pages—including those from the Pages Router.


🧪 Scripts

npm run build         # Compile TypeScript
npm test              # Run tests inside the /test directory
npm run format        # Format code with Prettier
npm run check-format  # Check code formatting

📘 License

ISC License


🐛 Issues / Feedback

File issues or feature requests at:
👉 https://github.com/grissly-man/next-runtime-sitemap/issues