Generate the sitemap.xml file for a Next.js site
Just copy and paste a file that will generate the sitemap.xml for a Nex.js site, including all routes and their last modified dates.
Requirements
Section titled “Requirements”Before using the file, make sure your project meets the following requirements:
- Next.js 13.3.0 or higher
- Next.js App Router
Add the file to your project
Section titled “Add the file to your project”Copy the sitemap.ts or sitemap.js file to your project’s app folder.
Edit the sitemapConfig object
Section titled “Edit the sitemapConfig object”Update the sitemapConfig object in the sitemap.ts or sitemap.js file with your site’s base URL and its manual routes.
const sitemapConfig: SitemapConfig = { baseUrl: "https://novajs.dev", manualRoutes: [ { route: "/react-hook-array", lastModified: "2025-06-14", }, { route: "/react-hook-async", lastModified: "2025-05-26", }, ],};const sitemapConfig = { baseUrl: "https://novajs.dev", manualRoutes: [ { route: "/react-hook-array", lastModified: "2025-06-14", }, { route: "/react-hook-async", lastModified: "2025-05-26", }, ],};