How to generate sitemap.xml with Next.js build-in server and Typescript?

Anna Coding
Anna Coding
Published in
1 min readJan 15, 2020

What is sitemap?

In this tutorial, I assume you already know what is sitemap and why do we need sitemap. If you want to know more about sitemap, I recommend you to check the following websites:

  1. Google manage your sitemaps 🔗
  2. Sitemaps XML format 🔗

Use Next.js API Routes to generate sitemap.xml

API routes provide a straightforward solution to build your API with Next.js. Any file inside the folder pages/api is mapped to /api/* and will be treated as an API endpoint instead of a page.

We use sitemap package to generate sitemap.xml in server side. Firstly, let us install it.

yarn add sitemap

Check the solution in below article link. It is integrated with gitlab codes snippet.

--

--

Anna Coding
Anna Coding

Free web, mobile, DevOps, cloud tutorials, issues & solutions. www.annacoding.com