Skip to main content

Function: createBlueskyPost()

createBlueskyPost(agent, input): Promise<CreateBlueskyPostResult>

Defined in: web/lib/bluesky/post-service.ts:97

Create a Bluesky post with an external embed (link card).

Parameters

agent

Agent

Authenticated ATProto Agent

input

CreateBlueskyPostInput

Post content with text and embed details

Returns

Promise<CreateBlueskyPostResult>

Created post result with URI, CID, and rkey

Remarks

This function:

  1. Creates RichText and detects facets (mentions, links, hashtags)
  2. Uploads thumbnail blob if provided (max 1MB)
  3. Creates the post record with external embed
  4. Returns the URI, CID, and rkey for linking to the post

The post is created in the user's PDS via ATProto. RichText.detectFacets() handles UTF-16 to UTF-8 byte conversion automatically.

Throws

Error if agent is not authenticated

Throws

Error if thumbnail upload fails

Throws

Error if post creation fails

Throws

Error with retryAfter for rate limiting (429)

Example

const agent = useAgent();
if (!agent) throw new Error('Not authenticated');

const result = await createBlueskyPost(agent, {
text: 'Check out this preprint!',
embed: {
uri: 'https://chive.pub/preprints/at://did:plc:abc/...',
title: 'Novel Approach to Quantum Computing',
description: 'We present a new method...',
thumbBlob: ogImageBytes,
},
});

// Open post on Bluesky
window.open(`https://bsky.app/profile/${agent.session.did}/post/${result.rkey}`);