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

sitemap-storage

v1.0.2

Published

Efficiently store and deliver the sitemap to your web pages

Readme

sitemap-storage

Efficiently store and deliver the sitemap to your web pages This library automatically helps in archiving sitemap records that exceed 45,000 urlsets or filesize of 45MB This library does not store sitemap record on the system's memory

Installation

npm install sitemap-storage --save

or using yarn

yarn add sitemap-storage

Usage

const SiteMapStorage = require("sitemap-storage");

const sitemap = new SiteMapStorage({
  hostname: "https://example.com",
  storageDirectory: "/absolute/path/to/sitemaps",
});

// adding a basic urlset data
sitemap.add(
  {
    changefreq: "always",
    loc: "/community/the-advancement-in-ai", // can also be an http link
    lastmod: Date.now(),
    priority: "0.9",
  },
  "./community" // <--- the directory to store the sitemap records in
);

// adding a more advance urlset data
sitemap.add(
  {
    changefreq: "weekly",
    loc: "https://example.com/posts/importance-of-large-scale-farming",
    lastmod: Date.now(),
    priority: "0.7",
    xhtml_link: [
      { rel: "alternate", hreflang: "fr", href: "/posts/importance-of-large-scale-farming?lang=fr" },
      { rel: "alternate", hreflang: "ko", href: "/posts/importance-of-large-scale-farming?lang=ko" },
      // ...more
    ],
    image: { loc: "path/to/image.jpg", title: "Testing Image Alt" },
    video: {
      content_loc: "path/to/playable/video.mp4",
      description: "Testing Video Description",
      thumbnail_loc: "/path/to/video/thumbnail.png",
      title: "Testing Video Title",
    }
  },
  "./posts"
);

// this should output an xml string

console.log(urlsetString);

Print sitemapindex

const SiteMapStorage = require("sitemap-storage");

const sitemap = new SiteMapStorage({
  hostname: "https://example2.com", // we can change the hostname to prefill the `loc` path
  storageDirectory: "/absolute/path/to/sitemaps",
});

// print sitemapindex relative to ./ and prefix each <loc> with '/sitemaps'
sitemap.prettySiteMapIndex('./', 'sitemaps').then(result => {
    // will output something like this:

    // <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

    // <sitemap>
        // <loc>https://example2.com/sitemaps/community/1737139860436.xml</loc>
        // <lastmod>2025-01-17</lastmod>
    // </sitemap>

    // <sitemap>
        // <loc>https://example2.com/sitemaps/posts/1737139860436.xml</loc>
        // <lastmod>2025-01-17</lastmod>
    // </sitemap>

    // </sitemapindex>

    console.log(result);
}); 

Print UrlSet Data

const SiteMapStorage = require("sitemap-storage");

const sitemap = new SiteMapStorage({
  hostname: "https://example2.com", // we can change the hostname to prefill `href` and `loc` path
  storageDirectory: "/absolute/path/to/sitemaps",
});

const urlsetSchemas = {
    'xmlns:xhtml': 'http://www.w3.org/1999/xhtml',
    'xmlns:image': 'http://www.google.com/schemas/sitemap-image/1.1'
};

sitemap.prettyUrlSet('./posts/1737117519084', urlsetSchemas)
  .then(urlsetString => {
    // will output something like this:
    
    // <?xml version="1.0" encoding="UTF-8"?>
    // <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    //         xmlns:xhtml="http://www.w3.org/1999/xhtml"
    //         xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
    // 
    //   <url>
    //     <loc>https://example.com/posts/importance-of-large-scale-farming</loc>
    //     <lastmod>2025-01-17</lastmod>
    //     <changefreq>weekly</changefreq>
    //     <priority>0.7</priority>
    //     <xhtml:link rel="alternate" hreflang="fr" href="https://example2.com/posts/importance-of-large-scale-farming%3Flang=fr" />
    //     <xhtml:link rel="alternate" hreflang="ko" href="https://example2.com/posts/importance-of-large-scale-farming%3Flang=ko" />
    //     <image:image>
    //       <image:loc>https://example2.com/path/to/image.jpg</image:loc>
    //       <image:title>Testing Image Alt</image:title>
    //     </image:image>
    //     <video:video>
    //       <video:loc>path/to/image.jpg</video:loc>
    //       <video:title>Testing Image Alt</video:title>
    //     </video:video>
    //   </url>

    // </urlset>
    console.log(urlsetString);
});