Skip to content

RSS Plugin

Serve an RSS feed of any collection. The plugin registers a public route that returns RSS 2.0 XML of published entries, sorted by date.

Install

Terminal window
bun add @timbl/plugin-rss

Use

Call createRssPlugin with the collection key, feed metadata, and your site URL. The plugin registers a route at /api/rss/:collection.xml by default.

import { defineCMS, defineCollection } from "timbl";
import { createRssPlugin } from "@timbl/plugin-rss";
export default defineCMS({
collections: [
defineCollection({
key: "posts",
labels: { singular: "Post", plural: "Posts" },
fields: [
{ key: "title", type: "text", required: true },
{ key: "slug", type: "slug", required: true },
{ key: "date", type: "date" },
{ key: "body", type: "markdown" },
{ key: "status", type: "select", options: ["draft", "published"] },
],
}),
],
plugins: [
createRssPlugin({
collection: "posts",
title: "My Blog",
description: "Posts about things",
siteUrl: "https://example.com",
}),
],
});

How it works

The plugin registers a GET route (public auth) that queries the collection for published entries sorted by -date, then renders the result as RSS 2.0 XML with the channel metadata you provide. Each entry becomes an <item> with title, link, guid, and pubDate.

The route reads each item’s title, slug, and date (or publishedAt if date is absent) from the stored record. If your collection uses different field keys, the feed will not populate correctly. Name your fields title, slug, and date, or fork the plugin.

Options

type RssPluginOptions = {
collection: string; // the collection key to feed
title: string; // feed channel title
description: string; // feed channel description
siteUrl: string; // used to build item links
routePath?: string; // optional, defaults to /api/rss/:collection.xml
};

collection, title, description, and siteUrl are required. routePath is optional and defaults to /api/rss/<collection>.xml. Override it if you want a different path.

Customizing the feed

The plugin is small and ships as source. If you need different item fields, a different sort order, or Atom format, the simplest path is to copy packages/plugin-rss/src/rss.ts into your project, adjust the query and XML generation, and register it as a plain route in your own plugin. See Plugins for the route registration API.

Contract tier

The plugin definition shape and the createRssPlugin factory are stable. The plugin uses routes and the public RouteContext, both stable surfaces. See Plugins and the HTTP API Reference.

See also