Skip to content

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.

Before using the file, make sure your project meets the following requirements:

  • Next.js 13.3.0 or higher
  • Next.js App Router

Copy the sitemap.ts or sitemap.js file to your project’s app folder.

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",
},
],
};