Steven Develops Icon

Steven Develops

All things engineering

Opinions are my own

BlogPortfolioContact
Skip to main content

Our Open Source RSS Feed Generator

Published on · In open-sourceby

Abstract representation of content syndication and RSS feeds
Abstract representation of content syndication and RSS feeds

Our Open Source RSS Feed Generator

As developers, we often rely on open-source libraries to simplify repetitive tasks, allowing us to focus on solving bigger problems. This philosophy inspired us to create and share @bliztek/feed-generator, a simple and lightweight Node.js library for generating RSS 2.0, Atom, and JSON feeds. By open-sourcing this project, we aim to give back to the developer community and help others implement feed generation without reinventing the wheel.

Why We Built This Library

The need for standardized content syndication is everywhere: blogs, news sites, podcasts, or any content-driven platform. Existing solutions often came with unnecessary complexities or lacked support for multiple feed formats. We wanted something:

  • Lightweight: No external dependencies.
  • Developer-Friendly: Easy-to-use API with TypeScript support.
  • Flexible: Fully customizable feed metadata and entries.
  • Reliable: Valid outputs for RSS 2.0, Atom, and JSON Feed formats.

Additionally, we are very cognizant of the risks associated with supply chain attacks. By striving to develop zero-dependency solutions for simple problems, we minimize vulnerabilities and offer a more secure library. As of now, this is the only RSS feed generator that operates with zero external dependencies.

Seeing this gap, we decided to build a solution that meets these criteria and share it with the open-source community.

Features

  • Unified API: Define your feed data once, output to RSS 2.0, Atom, or JSON Feed formats.
  • Type-Safe Development: Built with TypeScript with structured error handling via FeedValidationError.
  • Validation-Ready Outputs: All feeds pass online validators like W3C Feed Validator and JSON Feed Validator.
  • Customizable: Configure feed metadata and entries to fit your platform's needs.
  • HTML Sanitization: Optional XSS protection with whitelist-based sanitization.
  • Podcast Support: Full iTunes namespace integration for Apple Podcasts and Spotify compatibility.
  • No External Dependencies: Lightweight and easy to integrate.
  • ESM + CJS: Dual module builds with tree-shaking support.

Installation

You can quickly install the library using npm or Yarn:

npm install @bliztek/feed-generator

Or:

yarn add @bliztek/feed-generator

How to Use @bliztek/feed-generator

Step 1: Import the Feed Generator

import { generateFeed, generateFeeds } from "@bliztek/feed-generator";

Step 2: Define Your Feed Data

In v2, you define your feed data once using a unified structure that works across all formats:

const feed = {
  title: "My Blog Feed",
  link: "https://example.com",
  description: "The latest articles from my blog.",
  items: [
    {
      id: "https://example.com/post-1",
      title: "First Post",
      link: "https://example.com/post-1",
      summary: "A summary of the first post.",
      date: "2024-12-14T10:00:00Z",
    },
  ],
};

Step 3: Generate Feeds

Single Format

Use generateFeed to produce a specific format:

const rss = generateFeed(feed, "rss");
const atom = generateFeed(feed, "atom");
const json = generateFeed(feed, "json");

All Formats at Once

Use generateFeeds to produce all three formats simultaneously:

const { rss, atom, json } = generateFeeds(feed);

Fluent Builder API

For incremental feed construction, use the FeedBuilder:

import { FeedBuilder } from "@bliztek/feed-generator";

const rss = new FeedBuilder()
  .title("My Blog")
  .link("https://example.com")
  .description("Latest posts.")
  .addItem({ id: "1", title: "First Post" })
  .generate("rss");

Options

Both generateFeed and generateFeeds accept an optional options object:

const rss = generateFeed(feed, "rss", {
  sanitize: true, // Enable HTML sanitization (default: false)
  pretty: true,   // Pretty-print output (default: true)
});

Error Handling

Validation errors throw a structured FeedValidationError:

import { generateFeed, FeedValidationError } from "@bliztek/feed-generator";

try {
  generateFeed(feed, "rss");
} catch (e) {
  if (e instanceof FeedValidationError) {
    console.log(e.field);  // e.g. "title", "items[0].link"
    console.log(e.reason); // Human-readable explanation
  }
}

Validating Your Feeds

To ensure the generated feeds are valid, you can use:

Benefits of Having an RSS Feed

RSS feeds offer numerous benefits for both content creators and readers. They allow your audience to stay updated with your latest posts without needing to check your site manually. For creators, RSS feeds provide a standardized way to distribute content across multiple platforms, increase audience engagement, and improve visibility. Whether for blogs, news sites, or podcasts, having an RSS feed is a powerful tool for syndication and user convenience.

Enhancing SEO with RSS Feeds

  • Increased Indexing: RSS feeds ensure search engines quickly discover new content as they frequently crawl the feed for updates.
  • Backlink Opportunities: When platforms or readers subscribe and share, they may create backlinks, indirectly improving domain authority.
  • Improved Engagement: Subscribers are more likely to revisit and share your content, signaling relevance to search engines.
  • Content Syndication: Your feed enables broader distribution of your articles, increasing exposure and traffic.

Subscribing to Our RSS Feed

We use our @bliztek/feed-generator package in conjunction with MDX for Bliztek's website. If you are interested in subscribing to our RSS feed, you can use the following link: https://bliztek.com/rss.xml. Stay updated with the latest content and developments from our blog!

Get Involved

Open source thrives on collaboration. Whether you want to report a bug, suggest a feature, or contribute code, we welcome your involvement! Check out the GitHub repository for details.

Let's build something amazing together.

Conclusion

We're proud to contribute to the open-source ecosystem with a tool that simplifies feed generation for developers worldwide. By prioritizing security and simplicity, @bliztek/feed-generator is a dependable solution for modern developers. We hope this library makes your projects easier and more efficient. Try it out today, and let us know what you think!

I originally published this article on my web development company Bliztek, LLC Blog.

Steven Brown in Milan
Steven Brown

Let's Connect

If you've journeyed this deep into my site, you're exactly who I want to connect with — whether it's about a fresh project or just a friendly chat. Feel free to reach out through social media or my contact page.