How to add RSS feed in Next.js Blog

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • Appwrite - The Open Source Firebase alternative introduces iOS support
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • JetBrains - Developer Ecosystem Survey 2022
  • vercel

    Develop. Preview. Ship.

    In the above code, I've used the process.env.VERCEL_URL as the siteURL. You might be wondering why I used that. In my case, I am using vercel to host my website. So we need to pass the siteURL to the RSS. In the production or Preview in Vercel, it provides us the environment variable called VERCEL_URL which is nothing but your site root URL. For example We need the root URL for the production as well as the development phase because we need to check if our RSS is working or not. That's why I've chosen VERCEL_URL as the environment variable. My .env.local looks like this-

  • murder

    Large scale server deploys using BitTorrent and the BitTornado library (by ervinb)

    // lib/generateRssFeed.js import fs from "fs"; import { Feed } from "feed"; import { getAllPosts } from "./posts"; export default async function generateRssFeed() { const posts = getAllPosts(); const siteURL = process.env.VERCEL_URL; const date = new Date(); const author = { name: "John Doe", email: "[email protected]", link: "", }; // Creating feed const feed = new Feed({ title: "Your Blog name", description: "Your Blog description", id: siteURL, link: siteURL, image: `${siteURL}/favicon.ico`, favicon: `${siteURL}/favicon.ico`, copyright: `All rights reserved ${date.getFullYear()}, Jatin Sharma`, updated: date, // today's date generator: "Feed for Node.js", feedLinks: { rss2: `${siteURL}/rss/feed.xml`, // xml format json: `${siteURL}/rss/feed.json`, // json fromat }, author, }); // Adding blogs to the rss feed posts.forEach((post) => { const url = `${siteURL}/blog/${post.slug}`; feed.addItem({ title: post.title, id: url, link: url, description: post.excerpt, content: post.excerpt, author: [author], contributor: [author], date: new Date(, }); }); // generating the xml and json for rss fs.mkdirSync("./public/rss", { recursive: true }); fs.writeFileSync("./public/rss/feed.xml", feed.rss2()); fs.writeFileSync("./public/rss/feed.json", feed.json1()); }

  • Appwrite

    Appwrite - The Open Source Firebase alternative introduces iOS support . Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!

  • mdx

    Markdown for the component era

    I am assuming you already have your blog page where all the blogs are listed. I am using MDX for managing the blog content. You might be using the same or anything else that doesn't matter. The main thing is you need to have an array containing all the blogs.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts