NextJS
2 min read
25.12.2025
.md

Adding an RSS Feed to My Next.js Blog

Last updated: 08.02.2026

RSS feed illustartion
🎧

Audio Narration

Listen to this post

The blog now offers a fully-featured RSS 2.0 feed, built with the Next.js App Router and Sanity’s content API, so readers can easily subscribe and stay updated on new posts. The feed includes comprehensive metadata such as titles, descriptions, publication dates, author attribution via the Dublin Core namespace, category tags, and both image and audio enclosures. Auto-generated summaries populate the description field, and the feed is generated server-side at /posts/rss.xml using the same Sanity query as the main site to ensure consistency. Technically, the implementation emphasizes security and performance with proper XML escaping, aggressive caching (one hour with stale-while-revalidate), extended RSS namespaces (Dublin Core, Atom, Content Module), auto-discovery through HTML metadata, and graceful error handling that falls back to an empty feed if needed. The post also highlights why RSS still matters: it gives readers control over how they consume content, preserves privacy by avoiding tracking, remains platform-independent, and bypasses algorithmic filtering so every post reaches every subscriber. Readers can subscribe via any RSS reader using the provided feed URL, gaining access to both text and audio narration for each article.

I just added a fully-featured RSS feed to my blog, making it easy for readers to subscribe and stay updated on new posts. The implementation leverages Next.js App Router and Sanity's content API to generate a standards-compliant RSS 2.0 feed with extended features.

What's in the Feed

The RSS feed includes everything you'd expect from a modern feed:

  • Full post metadata including title, description, and publication dates
  • Author attribution using Dublin Core namespace
  • Category tags for easy filtering
  • Image enclosures for featured images
  • Audio enclosures for TTS narration
  • Auto-generated summaries in the description field

Technical Implementation

The feed is generated server-side using a Next.js API route at /posts/rss.xml. It queries all published posts from Sanity using the existing allPostsQuery, ensuring consistency with what's displayed on the site.

Key implementation details:

  • Proper XML escaping to prevent injection attacks
  • Aggressive caching (1 hour with stale-while-revalidate) to minimize server load
  • RSS 2.0 compliance with extended namespaces (Dublin Core, Atom, Content Module)
  • Auto-discovery via HTML metadata in the site layout
  • Graceful error handling with fallback empty feed

Why RSS Still Matters

Despite the rise of social media and email newsletters, RSS remains relevant for several reasons:

  • Reader control: Subscribers choose when and how to consume content
  • Privacy: No tracking or data collection
  • Platform independence: Works with any RSS reader
  • No algorithmic filtering: Every post reaches every subscriber

The Result

Readers can now subscribe to the blog using any RSS reader (Feedly, Inoreader, NetNewsWire, etc.) by visiting https://andreskristensen.blog/posts/rss.xml. The feed automatically updates whenever new posts are published, and includes both text content and audio narration for each article.

This addition makes the blog more accessible and gives readers another way to stay connected—one that respects their time and privacy.