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

svelte-sitemap

v4.0.4

Published

Small helper which scans your Svelte routes folder and generates static sitemap.xml

Readme

npm version Package License Build & Publish

🗺️ Svelte sitemap.xml generator

Generates sitemap.xml from your SvelteKit static routes — automatically, on every build.


  • ➡️ Designed for SvelteKit adapter-static with prerender option (SSG)
  • 🔷 TypeScript, JavaScript, CLI and Vite plugin version
  • 🔧 Useful options for customizing your sitemap
  • 🗂️ Support for sitemap index for large sites (50K+ pages)
  • ▲ 🟠 Works with Vercel and Cloudflare adapters and more...

📦 Install

npm install svelte-sitemap --save-dev
# yarn add svelte-sitemap --dev
# pnpm add -D svelte-sitemap
# bun add -d svelte-sitemap

🚀 Usage

If you're using SvelteKit with Vite (which is the default), you can integrate the sitemap generation directly into the Vite build pipeline.

Add the plugin to your vite.config.ts:

// vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import { svelteSitemap } from 'svelte-sitemap/vite'; // <-- Add svelte-sitemap vite plugin
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    sveltekit(),
    svelteSitemap({ domain: 'https://example.com' }) // <-- Configure the plugin with your options
  ]
});

The sitemap is generated automatically at the end of every vite build. All options are supported.


Alternative Methods

For other setups, the following methods are still supported but are deprecated in favor of the Vite plugin.

[!WARNING] Running the generator via CLI is an alternative. We recommend migrating to the Vite plugin instead.

Create a config file svelte-sitemap.config.ts in the root of your project:

// svelte-sitemap.config.ts
import type { OptionsSvelteSitemap } from 'svelte-sitemap';

const config: OptionsSvelteSitemap = {
  domain: 'https://www.example.com',
  trailingSlashes: true
  // ...more options below
};

export default config;

Then add svelte-sitemap as a postbuild script in package.json:

{
  "scripts": {
    "postbuild": "npx svelte-sitemap"
  }
}

After every build, the sitemap is generated in your build/ folder.

[!WARNING] Passing configuration options directly as CLI flags is deprecated and will be removed in a future version. Please use the Vite plugin or a config file instead.

Pass options directly as CLI flags — no config file needed:

{
  "scripts": {
    "postbuild": "npx svelte-sitemap --domain https://myawesomedomain.com"
  }
}

See all available flags in the Options table below.

Sometimes it's useful to call the script directly from code:

// my-script.js
import { createSitemap } from 'svelte-sitemap';

createSitemap({ domain: 'https://example.com', debug: true });

Run your script:

node my-script.js

⚙️ Options

Options are defined as config file keys (camelCase). Use it in your svelte-sitemap.config.ts file. The same options are also available as CLI flags for legacy use.

| Config key | CLI flag | Description | Default | Example | | ----------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------- | | domain | --domain, -d | Your domain [required] | - | domain: 'https://mydomain.com' | | outDir | --out-dir, -o | Custom build folder | build | outDir: 'dist' | | additional | --additional, -a | Additional pages outside of SvelteKit | - | additional: ['my-page', 'my-second-page'] | | ignore | --ignore, -i | Ignore files or folders (glob patterns) | [] | ignore: ['**/admin/**', 'my-secret-page'] | | trailingSlashes | --trailing-slashes, -t | Add trailing slashes | false | trailingSlashes: true | | resetTime | --reset-time, -r | Set lastModified time to now | false | resetTime: true | | changeFreq | --change-freq, -c | Set change frequency options | - | changeFreq: 'daily' | | debug | --debug | Show some useful logs | - | debug: true | | - | --help, -h | Display usage info | - | - | | - | --version, -v | Show version | - | - |

🔄 Migration to Vite Plugin

Migrating from the CLI or config file to the Vite plugin is quick and straightforward:

  1. Remove svelte-sitemap from package.json scripts:

    {
      "scripts": {
    -   "postbuild": "npx svelte-sitemap"
      }
    }
  2. Copy options from your config file (e.g., svelte-sitemap.config.ts) if you have one, and then delete it.

  3. Register the plugin in vite.config.ts: Import svelteSitemap and configure your options directly inside the plugin. The options object is 100% compatible, so you can copy and paste your configuration directly into svelteSitemap({...}):

    // vite.config.ts
    import { sveltekit } from '@sveltejs/kit/vite';
    import { svelteSitemap } from 'svelte-sitemap/vite';
    import { defineConfig } from 'vite';
    
    export default defineConfig({
      plugins: [
        sveltekit(),
        svelteSitemap({
          domain: 'https://example.com'
          // Paste your options object from svelte-sitemap.config.ts here.
          // Note: If migrating from CLI flags, convert kebab-case flags to camelCase options:
          // e.g. --ignore -> ignore: ['**/admin/**']
          //      --out-dir -> outDir: 'dist'
        })
      ]
    });

🙋 FAQ

🙈 How to exclude a directory?

Use ignore with glob patterns. For example, to ignore all admin folders and one specific page:

// svelte-sitemap.config.ts
import type { OptionsSvelteSitemap } from 'svelte-sitemap';

const config: OptionsSvelteSitemap = {
  domain: 'https://www.example.com',
  ignore: ['pages/my-secret-page', '**/admin/**']
};

▲ Vercel adapter

If you're using adapter-vercel, the output directory is different from the default build/:

// svelte-sitemap.config.ts
import type { OptionsSvelteSitemap } from 'svelte-sitemap';

const config: OptionsSvelteSitemap = {
  domain: 'https://www.example.com',
  outDir: '.vercel/output/static'
};

Or check out other solutions and join the discussion.


🟠 Cloudflare adapter

If you're using @sveltejs/adapter-cloudflare, you need to exclude sitemap.xml from Cloudflare's routing in svelte.config.js:

-import adapter from '@sveltejs/adapter-auto';
+import adapter from '@sveltejs/adapter-cloudflare';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    kit: {
-       adapter: adapter()
+       adapter: adapter({ routes: { include: ['/*'], exclude: ['<all>', '/sitemap.xml'] }})
    }
};

export default config;

🐞 Common issues

❌ Error: Missing folder

× Folder 'build/' doesn't exist. Make sure you are using this library as 'postbuild'
  so 'build/' folder was successfully created before running this script.

Make sure the output folder exists. If your build outputs to a different folder than build/, use the outDir option in your config file.


❌ Error: Missing html files

× There is no static html file in your 'build/' folder.
  Are you sure you are using Svelte adapter-static with prerender option?

This library is intended for adapter-static with the prerender option (SSG). If there are no static HTML files in your build folder, this library won't work for you :'(


⭐️ Show your support

Give a ⭐️ if this project helped you!

Or if you are brave enough consider making a donation for some 🍺 or 🍵 ;)

🕵️ Privacy Policy

I DO NOT STORE ANY DATA. PERIOD.

I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.

That's why, with this library, what happens on your device stays on your device till disappear.

🤝 Contributing

I welcome you to customize this according to your needs ;)

Pull requests for any improvements would be great!

Feel free to check issues page.

🛠️ Developing and debugging this library

git clone [email protected]:bartholomej/svelte-sitemap.git
cd svelte-sitemap
yarn
yarn start

Run demo locally

You can find and modify it in ./demo.ts file

yarn demo

🙏 Credits

📝 License

Copyright © 2026 Lukas Bartak

Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)

All contents are licensed under the MIT license.