AD
Boost Your Brand on BlueSky—Exclusive banner space to amplify your reach within the BlueSky community.
BSkyInfo LogoBskyInfo
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryArticlesGuidesGlossaryBluesky SDKsSponsor
Submit
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryGuidesGlossaryArticlesBluesky SDKsSponsorSubmit
  1. SDKs
  2. /JavaScript
  3. /bluesky-comments
czue

bluesky-comments

A JavaScript SDK for Bluesky and AT Protocol by czue

Add a comments thread to any page using bluesky.

GitHub Stats

186stars
8forks
5contributors
6open issues

Dates

Created:November 25, 2024
Last updated:May 18, 2025

README

The following content is from bluesky-comments's GitHub repository. All rights reserved by the original author.

Bluesky Comments

Embed Bluesky comments on your website easily.

Write up and demo here.

Installation in a Node.js project as a React component

To use this library in a React project, first install the library:

npm install bluesky-comments

Then import it (and the CSS) in your React app/page/component:

import 'bluesky-comments/bluesky-comments.css'
import { BlueskyComments } from 'bluesky-comments';

And use it in any React component like this:

function App() {
  return (
    <>
      <div>Comments Will Display Below</div>
      <BlueskyComments author="you.bsky.social" />
    </>
  )
}

See the Usage section below for details on the options and API.

Installation on any website via CDN

To add a comments section to any website, follow these steps

1. Add an element to your page where you want the comments to show up

Add something like this to your site:

<div id="bluesky-comments"></div>

You can use whatever id you want, but it has to match the container id used in the getElementById call in the usage step.

2. Add the CSS files

Add the default styles the page <head> somewhere in a base template:

<link rel="stylesheet" href="https://unpkg.com/bluesky-comments@<VERSION>/dist/bluesky-comments.css">

3. Add source maps for React

Add the following importmap to your page anywhere before you use the library:

<script type="importmap">
{
  "imports": {
    "react": "https://esm.sh/react@18",
    "react-dom/client": "https://esm.sh/react-dom@18/client"
  }
}
</script>

4. Import the library and instantiate the component with React in an ES module script:

<script type="module">
  import { createElement } from 'react';
  import { createRoot } from 'react-dom/client';
  import { BlueskyComments } from 'https://unpkg.com/bluesky-comments@<VERSION>/dist/bluesky-comments.es.js';

  const author = 'you.bsky.social';
  const container = document.getElementById('bluesky-comments');
  const root = createRoot(container);
  root.render(
    createElement(BlueskyComments, {
      "author": author,
    })
  );
</script>

See the Usage section below for details on the options and API.

Usage

Examples in this section use the React JSX syntax. If you're installing on a project that doens't use JSX or any build tooling (i.e. a regular website), you can instead use the createElement function and pass the react options in.

For example, the following two examples are equivalent:

React JSX:

<BlueskyComments
  author="you.bsky.social"
  uri="https://bsky.app/profile/coryzue.com/post/3lbrko5zsgk24"
/>

Equivalent without JSX:

root.render(
  createElement(BlueskyComments, {
    author: "you.bsky.social",
    uri: "https://bsky.app/profile/coryzue.com/post/3lbrko5zsgk24",
  })
);

Initializing the library based on the author

<BlueskyComments author="you.bsky.social"  />

If you use this mode, the comments section will use the most popular post by that author that links to the current page.

Initializing the library based on a post URL

<BlueskyComments uri="https://bsky.app/profile/coryzue.com/post/3lbrko5zsgk24" />

If you use this mode, the comments section will use the exact post you specify. This usually means you have to add the comments section only after you've linked to the article.

(Advanced) Providing custom default empty states

You can pass in a onEmpty callback to handle the case where there are no comments rendered (for example, if no post matching the URL is found or there aren't any comments on it yet):

<BlueskyComments
    uri="https://bsky.app/profile/coryzue.com/post/3lbrko5zsgk24"
    author="you.bsky.social"
    onEmpty={
      (details) => {
        console.error('Failed to load comments:', details);
        document.getElementById('bluesky-comments').innerHTML =
          'No comments on this post yet. Details: ' + details.message;
      }
    }
});

(Advanced) Filtering comments

You can pass in an array of filters to the commentFilters option. These are functions that take a comment and return a boolean. If any of the filters return true, the comment will not be shown.

A few default filters utilities are provided:

  • BlueskyFilters.NoPins: Hide comments that are just "📌"
  • BlueskyFilters.NoLikes: Hide comments with no likes

You can also use the following utilities to create your own filters:

  • BlueskyFilters.MinLikeCountFilter: Hide comments with less than a given number of likes
  • BlueskyFilters.MinCharacterCountFilter: Hide comments with less than a given number of characters
  • BlueskyFilters.TextContainsFilter: Hide comments that contain specific text (case insensitive)
  • BlueskyFilters.ExactMatchFilter: Hide comments that match text exactly (case insensitive)

Pass filters using the commentFilters option:

import {BlueskyComments, BlueskyFilters} from 'bluesky-comments';

<BlueskyComments
    // other options here
    commentFilters={[
      BlueskyFilters.NoPins,  // Hide pinned comments
      BlueskyFilters.MinCharacterCountFilter(10), // Hide comments with less than 10 characters
    ]}
/>

You can also write your own filters, by returning true for comments you want to hide:

const NoTwitterLinksFilter = (comment) => {
  return (comment.post.record.text.includes('https://x.com/') || comment.post.record.text.includes('https://twitter.com/'));
}
<BlueskyComments
    // other options here
    commentFilters={[
      NoTwitterLinksFilter,
    ]
/>

(Removed) Legacy installation using <script> tags and UMD

Previous versions of this library recommended installing like this:

<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/bluesky-comments@<VERSION>/dist/bluesky-comments.umd.js"></script>

And initializing the comments in a standard <script> tag with an init function:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    const uri = 'https://bsky.social/coryzue.com/posts/3jxgux';
    if (uri) {
      BlueskyComments.init('bluesky-comments', {uri});

      // Legacy API (still supported but deprecated)
      initBlueskyComments('bluesky-comments', {uri});
    }
  });
</script>

This option has been removed in version 0.9.0 and new projects should use the ES module syntax above.

Development

To develop on this package, you can run:

npm install
npm run dev

This will set up a local development server with a simple page showing comments, and watch for changes.

You can also run npm run build (build once) or npm run watch (watch for changes) to copy the built files to the dist directory. From there you can reference the files in your own projects.

Related SDKs

mary-extatcute

a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky.

318•JavaScript
aliceisjustplayinglabeler-starter-kit-bsky

Use this repository to get started with your own Bluesky Labeler.

167•JavaScript
bluesky-socialfeed-generator

ATProto Feed Generator Starter Kit

1856•JavaScript
bluesky-socialatproto

AT Protocol Reference Implementation (TypeScript)

8526•JavaScript
skyware-jsfirehose

A dead simple client for subscribing to an ATProto Relay ("firehose").

37•JavaScript
skyware-jsjetstream

A fully typed client for the Bluesky Jetstream (https://github.com/bluesky-social/jetstream) service.

47•JavaScript

Resources

GitHub Repository

License

MIT

Author

czue
czue

Activity

Last commit: May 18, 2025
Commit frequency: Unknown

Our Sponsors

Your Brand Here!

50K+ engaged viewers every month

Limited spots available!

📧 Contact us via email🦋 Contact us on Bluesky
BSkyInfo LogoBskyInfo

The Most Comprehensive Bluesky Tools Directory

Stay updated with the latest Bluesky tools and ecosystem news 🦋

Bluesky butterfly logo
Quick LinksSubmit a ToolSponsorAboutLegal Information
ToolsFeed DirectoryLabeler DirectorySchedulingAnalyticsAll ToolsCategoriesCollectionsTags
ResourcesArticlesBluesky GuidesBluesky GlossaryBluesky SDKsBluesky ResourcesSkyRaffleMeida Coverage
Our ProductsRaffleBlueAiTeach ToolsLaiewAI affiliate listFirsto

This website may contain affiliate links

© 2025 BskyInfo. All rights reserved.