Adding comments to this blog
5 February 2024 - by @mozzius.dev
This blog now has comments!
That might not sound particularly impressive, since I think most people would consider "comments on blogs" to be a Solved Problem. But I decided to go about it in a bit of a different way - all the comments are fetched directly from Bluesky. And I think the ease with which I did that goes a long way to demonstrating the power of Bluesky's Open Network, and is possibly worth talking about a little bit.
Bluesky is completely open
When I say "Bluesky is completely open", I really mean it. You don't even need an API key to query the AppView. Combined with the excellent tooling that Bluesky provides meant that implementating this feature took about hour, from scratch. Granted, I've been working with the API for a while now, but I think that's still pretty impressive.
Here's the code I used to fetch the comments (slightly simplified for clarity):
In the actual implementation, I don't use
BskyAgent
in favour of usingfetch
directly, due to Next.js overriding thefetch
function, but this version is a bit more readable and typesafe. And it's basically the same under the hood.
Simply make a <Comment />
component that renders a Bluesky post, and you're done! It's really that simple.
See my other blog post for a step-by-step guide on how to render a Bluesky post. My blog comments take it one step futher by rendering the replies recursively, to make a threaded comment section.
What this means
"The organization is a future adversary"
- Paul Frazee
Bluesky talks a lot about being "Billionaire-proof", and I think the open API is a critical part of that. Due to it's decentralised nature, it's not just open, it's "locked open" - Bluesky (the company) couldn't start locking off access even if they wanted to. This is in harsh contrast to X (formerly Twitter) turning off the free API, and making the paid API much more expensive, and Reddit suddenly charging 3rd party apps like Apollo $20 million a year for it's previously free API (instantly killing the 3rd party ecosystem).
This is critical to building trust in the platform among the developer community that Bluesky is trying to foster, and I think it's a big part of why Bluesky has seen an explosion of community projects. It's also a big part of why I'm so excited to be building on it. I don't have to worry that Bluesky will get bought out and "pull a Reddit" on me, because they literally can't. This matters, whether you want to add a little comment section to your blog, all the way up to building a full-fledged client.
I think this is also great for non-developers too. I completely stopped using Reddit when they killed Apollo, because the official app is garbage. That's not something you have to worry about with Bluesky, and it goes so much deeper than just the app. Every part of the platform can be swapped out, and that's a really powerful thing. We've watched platform after platform succumb to enshittification, and even if Bluesky (the company) follows suit, Bluesky (the community) doesn't have to.
This little comments section project - sure, it's pretty frivolous, but I love that Bluesky doesn't shy away from creativity. They want you to build cool things with what they've built. I think that's great.
Overall, I'm really optimistic about the future of Bluesky, and I'm excited to see what else is possible.
Let me know what you think in the all-new comments!
- Samuel (@mozzius.dev)