What next-sitemap does
next-sitemap is a TypeScript package that generates sitemap files and a robots.txt for Next.js sites. It runs after the build as a postbuild script, so it covers static, pre-rendered, dynamic and server-side pages in one pass. A config file in the project root sets the site URL, whether robots.txt is generated, and other options, and the package loads environment variables from .env files by default.
Large sites can be split across several sitemap files with the sitemapSize option, and from version 2 onwards the package can emit an index sitemap that points to them. Url sets can carry Google News, image and video entries. Two helpers, getServerSideSitemap and getServerSideSitemapIndex, generate sitemaps at request time for server-rendered routes.
Key features
- Postbuild sitemap generation
- Add next-sitemap as the postbuild script so sitemap files and robots.txt are written after next build.
- Root config file
- next-sitemap.config.js sets siteUrl, generateRobotsTxt and other options, and environment variables load from .env files by default.
- Index sitemap output
- From v2.x onwards the package can write an index sitemap that lists the individual sitemap files.
- Sitemap splitting by size
- The sitemapSize property splits a large sitemap into multiple files.
- Custom transformation function
- A user supplied transformation function adds your own logic to the default sitemap generation step.
- Additional paths function
- The additionalPaths function adds paths on top of those collected during the build.
- News, image, video entries
- Url sets can include extra Google News, image and video sitemap entries.
- Server side sitemap helpers
- getServerSideSitemap and getServerSideSitemapIndex produce sitemaps at request time for dynamic routes.
- Custom config file flag
- Pass --config <file>.js to the build command to use a config file with another name.
- pnpm setup note
- pnpm users need to create an .npmrc file before the postbuild command runs.
- TypeScript JSDoc typing
- A JSDoc line in next-sitemap.config.js gives type checking against the IConfig interface.
How it works
- Install the package with yarn add next-sitemap inside the Next.js project.
- Create next-sitemap.config.js in the project root and set siteUrl and generateRobotsTxt.
- Add next-sitemap to the postbuild script in package.json.
- Run next build so the postbuild step writes the sitemap files and robots.txt.
- Add getServerSideSitemap in server-rendered routes for pages built at request time.
- Exclude the server index sitemap route from robots.txt if it should not be crawled.
Plans and pricing
The package is published under the MIT licence at no charge, and the material lists no paid tiers.
Integrations and platforms
Works with
- Next.js
- Yarn
- pnpm
- Google News
Available as
- CLI
Repository facts
- Repositoryiamvishnusankar/next-sitemap
- LanguageTypeScript
- Stars3752
- Forks138
- LicenceMIT
- Created2020-08-02
- Last commit2026-05-13
- Open issues8
- next-sitemap
- nextjs
- react
- seo
- sitemap
- sitemap-generator
- typescript
Services and details
Does SEO work itself
YesFree plan or free tools
YesAPI or MCP server
Yes
No information yet on keyword research, content optimization, writes content with AI, technical audits, rank tracking, backlinks and link building, local SEO, AI search visibility, free trial, WordPress plugin, browser extension, built for agencies. The website did not say; check with the vendor.
About the company
- Company iamvishnusankar
- Website: github.com/iamvishnusankar/next-sitemap
Listing compiled from public sources and the product's own website. Last updated 2026-11-12. Report a correction or request removal. Back to GitHub repos.