next-sitemap

CLI that generates sitemaps and robots.txt for Next.js sites

Tool
npm
v4.2.3
3,744stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity16
Maintenance48
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
69/100Good
Architecture68
Code Quality74
Innovation55
Learning Curve80

next-sitemap is a build-time CLI tool that generates sitemap.xml, sitemap indexes, and robots.txt for Next.js applications, covering static, pre-rendered, dynamic, and server-rendered pages alike. Run as a postbuild script, it scans the build output to enumerate pages automatically, then applies a next-sitemap.config.js file to control priorities, change frequencies, exclusions, and multi-sitemap splitting for large sites.

It handles the awkward cases that hand-written sitemaps miss: dynamic routes populated via getServerSideProps, i18n locale variants, and sites large enough to need sitemap indexes split across multiple files. Because it runs entirely from the CLI against build artifacts, it requires no runtime code changes to the application itself beyond a config file and a postbuild script entry.

What You Get

  • A postbuild CLI command that generates sitemap.xml automatically after next build
  • Support for static, dynamic, server-rendered, and i18n-localized page routes
  • Automatic sitemap index splitting for large sites via a configurable page-count threshold
  • robots.txt generation with configurable disallow rules and sitemap references
  • A getServerSideSitemap helper for fully dynamic, on-demand sitemap generation
  • Custom transform functions to set per-URL priority, changefreq, and lastmod values

Common Use Cases

  • Generating a production sitemap.xml automatically as part of a Next.js CI/CD build pipeline
  • Producing a robots.txt with environment-specific disallow rules (staging vs. production)
  • Splitting a sitemap into multiple indexed files for a site with tens of thousands of pages
  • Building a dynamic sitemap for a marketplace or blog where pages are generated from a database

Under The Hood

Architecture - The CLI entrypoint (packages/next-sitemap/src/cli.ts) runs a clear pipeline of single-purpose classes: ConfigParser loads next-sitemap.config.js and runtime paths, ManifestParser reads the Next.js build manifest to enumerate rendered pages, UrlSetBuilder turns that manifest into a normalized URL set applying per-page transforms, and ExportableBuilder chunks the set into sitemap files (splitting into an index when generateIndexSitemap is enabled) and writes robots.txt before exporting everything to disk. Tech Stack - A TypeScript monorepo managed with Turborepo and Bun workspaces (packages/next-sitemap, examples/*, docs), publishing dual ESM/CJS builds with generated type declarations, and depending on fast-xml-parser for sitemap XML generation. Code Quality - Each builder and parser has a colocated __tests__ directory with unit tests and Jest/Bun snapshot fixtures (e.g. generate-robots-txt.test.ts, create-url-set.test.ts, absolute-url.test.ts), and the test script runs with coverage in CI via azure-pipeline.yml, reflecting deliberate test coverage over the core sitemap/robots-txt generation logic. API Design - The tool’s primary interface is a single next-sitemap.config.js file plus a postbuild script entry, requiring no changes to application route code for static/SSR pages; the separate getServerSideSitemap helper extends the same design to fully dynamic routes without introducing a second configuration system.

Used by 7 apps in this directory

TypeScript
76%
AGPL 3.0

Abby

Developer Tools · Product Management

167

Statically typed feature flags, remote config, and A/B testing with framework-native SDKs for TypeScript teams.

View details
30
Repo Health
70
Technical
63
Dependency
Built with
TypeScript76%
MDX18%
Updated 1 years ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
TypeScript
75%
Other

Jan

AI Assistants

44,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript75%
Rust21%
Updated today
TypeScript
99%
MIT

KeystoneJS

CMS · Developer Tools

9,957

The superpowered headless CMS for developers built with GraphQL and React

View details
91
Repo Health
81
Technical
64
Dependency
Built with
TypeScript99%
Updated yesterday
Python
51%
AGPL 3.0

LearnHouse

Learning Management · CMS

2,178

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
89
Repo Health
77
Technical
67
Dependency
Built with
Python51%
TypeScript48%
Updated 3 days ago
TypeScript
99%
Apache 2.0

Onlook

Design Tools · AI Design Tools

26,512

An open-source, AI-first visual editor that lets designers and developers build, style, and deploy React apps directly in code — no handoff required.

View details
66
Repo Health
80
Technical
68
Dependency
Built with
TypeScript99%
Updated 4 weeks ago
TypeScript
96%
MIT

Payload CMS

Developer Tools · Blogging · CMS

44,258

The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
TypeScript96%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search