explaingit

iamvishnusankar/next-sitemap

Analysis updated 2026-07-03

3,732TypeScriptAudience · developerComplexity · 1/5Setup · easy

TLDR

A tool for Next.js sites that automatically generates sitemap.xml and robots.txt files after each build so search engines can discover and index all your pages.

Mindmap

mindmap
  root((next-sitemap))
    What it does
      Generates sitemap.xml
      Generates robots.txt
      Runs after Next.js build
    Features
      Multi-file split
      Custom transforms
      Per-page priority
      URL exclusions
    Configuration
      Config file
      Build script hook
    Audience
      Next.js developers
      SEO-focused teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Automatically generate a sitemap.xml for a Next.js site after each build so search engines discover all static and server-rendered pages.

USE CASE 2

Split a large sitemap into multiple indexed files when a site has more URLs than a single sitemap file can hold.

USE CASE 3

Generate a robots.txt file alongside the sitemap by adding a single option to the next-sitemap config.

USE CASE 4

Exclude specific URL patterns from the sitemap or customize change frequency and priority per page using a transform function.

What is it built with?

TypeScriptNode.jsNext.jsnpm

How does it compare?

iamvishnusankar/next-sitemapshopify/hydrogen-v1fortawesome/react-fontawesome
Stars3,7323,7313,736
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderateeasy
Complexity1/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
No license information is provided in the explanation.

In plain English

next-sitemap is a tool for Next.js websites that automatically generates sitemap.xml and robots.txt files after you build your site. A sitemap is a file that tells search engines like Google which pages exist on your website and how often they change, which helps with search indexing. Without a sitemap, search engines have to discover your pages on their own, which can be slow or incomplete. Setup is straightforward: add a small configuration file to your project with your site's URL, then add a single line to your build scripts so that next-sitemap runs automatically after the Next.js build finishes. It picks up all the pages in your site, including static pages, pages pre-generated at build time, and dynamic pages that are built on the server when someone visits them. For larger websites, the tool can split the sitemap into multiple files automatically. Search engines have limits on how many URLs a single sitemap file should contain, so next-sitemap generates an index sitemap that points to all the individual files when the URL count gets large. You can configure the threshold yourself, for example splitting into new files every 7,000 URLs. Configuration options let you control how often pages are marked as changing (change frequency), the priority assigned to each page, which URLs to exclude, whether to generate a robots.txt file, and how to handle server-side rendered pages that fall outside the static build output. A custom transformation function is available if you need to modify which URLs appear in the sitemap or adjust their metadata per page. The library is written in TypeScript and distributed as an npm package. It integrates directly into the standard Next.js build workflow, so it runs automatically on each build with no extra steps beyond initial setup.

Copy-paste prompts

Prompt 1
How do I install next-sitemap and configure it to generate sitemap.xml with my production domain automatically after every Next.js build?
Prompt 2
My Next.js site has 20,000 pages. How do I configure next-sitemap to split the sitemap into multiple files with an index sitemap at 7,000 URLs per file?
Prompt 3
How do I exclude all URLs matching /admin/* and /api/* from the sitemap generated by next-sitemap?
Prompt 4
How do I use next-sitemap's transform function to give blog post pages a higher priority and weekly change frequency, while giving tag pages a lower priority?
Prompt 5
How do I configure next-sitemap to generate a robots.txt file that disallows crawling of /private/* paths?

Frequently asked questions

What is next-sitemap?

A tool for Next.js sites that automatically generates sitemap.xml and robots.txt files after each build so search engines can discover and index all your pages.

What language is next-sitemap written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, Next.js.

What license does next-sitemap use?

No license information is provided in the explanation.

How hard is next-sitemap to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is next-sitemap for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub iamvishnusankar on gitmyhub

Verify against the repo before relying on details.