PACKAGES

Rasengan Sitemap

@rasenganjs/sitemap generates a spec-compliant sitemap.xml for a Rasengan app, in ssr or prerender (SSG) mode. It's a standalone CLI that runs as a separate step after rasengan build, not a Vite plugin, so it always sees the final, complete build output.

Installation

Terminal
npm install -D @rasenganjs/sitemap

Usage

Create a rasengan-sitemap.config.js at your project root:

rasengan-sitemap.config.js
import { defineSitemapConfig } from '@rasenganjs/sitemap'; export default defineSitemapConfig({ siteUrl: 'https://your-site.com', // required changefreq: 'weekly', // optional priority: 0.7, // optional exclude: ['/admin/*'], // optional, glob against the route path generateRobotsTxt: false, // optional, off by default });

Then run the CLI after your build:

Terminal
rasengan build && rasengan-sitemap

Or wire it into your package.json:

package.json
{ "scripts": { "build": "rasengan build && rasengan-sitemap" } }

rasengan-sitemap reads the build's config.json to know which mode the app was built in, then writes sitemap.xml into the same directory the app actually produced:

  • prerender: truestatic/sitemap.xml
  • ssr: true, prerender: falsedist/client/sitemap.xml

What Gets Excluded Automatically

  • The catch-all */404 route.
  • _api/ routes, dispatched through a separate router and never part of the page route tree.
  • Any route matching a source in your rasengan.config.js's redirects(), a URL that immediately redirects elsewhere is a low-quality sitemap entry.
  • Anything matching your own exclude glob patterns.

Per-Route Overrides

For control beyond the static changefreq/priority defaults, use transform:

rasengan-sitemap.config.js
import { defineSitemapConfig } from '@rasenganjs/sitemap'; export default defineSitemapConfig({ siteUrl: 'https://your-site.com', transform: async (path) => ({ loc: path, changefreq: path === '/' ? 'daily' : 'weekly', priority: path === '/' ? 1.0 : 0.7, }), });

robots.txt Generation

Set generateRobotsTxt: true to also write a minimal robots.txt alongside sitemap.xml, with a Sitemap: line pointing at it. Off by default, so it never silently overwrites a hand-written robots.txt.

Community

Join the Rasengan.js community to get support, ask questions, and share your projects:

Let's build something amazing with Rasengan.js! 🚀

License

This package is MIT licensed.