POSSE to Bluesky with the AT Protocol

A Node script at the end of every deploy that posts new articles from the RSS feed to Bluesky as rich link cards, straight through the AT Protocol API.

Article Created Updated

Reviewed by adrian on

POSSE (Publish on your Own Site, Syndicate Elsewhere) means the article lives on my site first and Bluesky gets a copy. If Bluesky disappears, the original is unaffected. On my old site I wanted this as the last step of every deploy: no copying links into a client by hand, and no third-party webhook service.

The setup

  • Site: an Astro 6 static build with separate RSS feeds per content type.
  • Deploy: a shell script that builds, syncs to a VPS with rsync, sends webmentions and then syndicates.
  • Bluesky: an app password and the AT Protocol API directly. No SDK, no bridge.

Separate RSS feeds

Before this the site had one feed for everything. It stayed, and four feeds per type joined it:

/rss.xml            all content
/rss/articles.xml   articles only
/rss/notes.xml      notes only
/rss/links.xml      links only
/rss/photos.xml     photos only

Readers who want articles but no photos can subscribe to just those. And the syndication script, like webmention.app, can target one content type instead of filtering a mixed feed.

The syndication script

scripts/bluesky-syndicate.mjs runs locally as the last deploy step. It reads the live RSS feed and posts every article that has not been posted yet. The state lives in .bluesky-posted.json, at first a flat array of GUIDs:

const posted = existsSync(STATE_FILE)
    ? JSON.parse(readFileSync(STATE_FILE, 'utf8'))
    : [];

const newItems = items.filter((item) => !posted.includes(item.guid));

After a successful post the GUID is appended and the file written back. A later step turned the array into a map that also records the Bluesky URL, see Improving Bluesky Syndication.

Authentication with an app password

Posting needs an authenticated session, and the main account password does not belong in a script. Bluesky's settings create app passwords, scoped credentials for exactly this. The script opens a session with com.atproto.server.createSession:

const authRes = await fetch(`${BSKY_API}/com.atproto.server.createSession`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ identifier: IDENTIFIER, password: APP_PASSWORD }),
});
const { accessJwt, did } = await authRes.json();

A plain URL in the post body renders as plain text. What people share is the link card with title, description and thumbnail. Bluesky's app.bsky.embed.external produces that card, but the thumbnail has to be uploaded as a blob before the post is created.

The script fetches the live article page as text and pulls the content attribute of the <meta property="og:image"> tag out of it with a regular expression. Then it downloads the image and uploads it:

const buffer = await fetch(ogImageUrl).then((r) => r.arrayBuffer());
const uploadRes = await fetch(`${BSKY_API}/com.atproto.repo.uploadBlob`, {
    method: 'POST',
    headers: {
        'Content-Type': contentType,
        Authorization: `Bearer ${accessJwt}`,
    },
    body: buffer,
});
const { blob } = await uploadRes.json();

The blob reference goes into the post record:

const record = {
    $type: 'app.bsky.feed.post',
    text: item.title,
    createdAt: new Date(item.pubDate).toISOString(),
    embed: {
        $type: 'app.bsky.embed.external',
        external: {
            uri: item.link,
            title: item.title,
            description: item.description,
            thumb: blob,
        },
    },
};

The OG image itself came from Satori at build time: a dark card with the title in large type, the description below and an accent stripe at the top. One image per article, at /og/articles/[slug].png.

Post timestamps

createdAt is the article's publish date from the RSS pubDate, not the deploy time. An article from weeks ago lands at its own place on the timeline instead of looking new.

Several articles often share a publish date after a batch session. In my case, posts with an identical createdAt disappeared, and only one of them showed up. An offset of one second per item keeps them apart:

const createdAt = new Date(baseDate.getTime() + i * 1000).toISOString();

Wiring it into the deploy script

The credentials come from .env.production, which is never committed:

BLUESKY_IDENTIFIER="$(grep -E '^BLUESKY_IDENTIFIER=' "$PRODUCTION_ENV_FILE" | cut -d'=' -f2-)"
BLUESKY_APP_PASSWORD="$(grep -E '^BLUESKY_APP_PASSWORD=' "$PRODUCTION_ENV_FILE" | cut -d'=' -f2-)"

if [[ -n "$BLUESKY_IDENTIFIER" && -n "$BLUESKY_APP_PASSWORD" ]]; then
  BLUESKY_IDENTIFIER="$BLUESKY_IDENTIFIER" \
  BLUESKY_APP_PASSWORD="$BLUESKY_APP_PASSWORD" \
  node "$SCRIPT_DIR/bluesky-syndicate.mjs"
fi

Without credentials the block is skipped and the deploy still succeeds. The full order on every deploy: build, rsync, redeploy on the VPS, send webmentions, syndicate to Bluesky.

Takeaways

  • The whole thing was about 200 lines of script. The canonical copy stays on my own site.
  • Rich link cards need the blob upload first; the embed only references it.
  • Deploy-time timestamps make everything look as if it was posted today.

Based on

  • POSSE to Bluesky with the AT Protocol (raw/2026/2026-03-23/posse-to-bluesky-with-the-at-protocol.md) [post]

More on this

Topic

  • IndieWeb Publishing on your own domain first and connecting personal websites with open standards such as Webmention and Microformats.

Basis for

  • Bluesky Reactions as Webmentions with Bridgy Bridgy polls Bluesky for likes, reposts and replies to syndicated posts and sends them back as webmentions, so they appear on the original post.
  • Improving Bluesky Syndication Notes as a second source, OG images compressed with Sharp below the blob limit, publish dates as timestamps and Bluesky URLs in a committed state file.
  • POSSE to Mastodon A Mastodon syndication script for articles and notes: state keyed by canonical URL, OG image uploads that fail open, backoff on 429, dry runs and batch limits.

Uses

  • Astro Tool for building websites from content such as Markdown. Ships plain HTML by default and only loads JavaScript where it is needed.

Mentioned

  • Joining the IndieWeb Why I made my own domain the canonical home of everything I publish, and how rel=me and h-card verified my identity on the old site.

Show in the graph view