Ditch the DIY Drama: Why Use Fedify Instead of Building ActivityPub from Scratch?
Ditch the DIY Drama: Why Use Fedify Instead of Building ActivityPub from Scratch?
Ditch the DIY Drama: Why Use Fedify Instead of Building ActivityPub from Scratch?
Ditch the DIY Drama: Why Use Fedify Instead of Building ActivityPub from Scratch?
Ditch the DIY Drama: Why Use Fedify Instead of Building ActivityPub from Scratch?
Because outsourcing your core business processes is a bad idea. A fediverse app that relies on a library to do all the fediverse stuff is going to have a bad time. Not straight away, but eventually.
I'm not sure about that. Sometimes it's more about properly applying libraries. Thinking of database handling or cryptography
Imagine you want to write a competitor to PostgreSQL and you start out by importing SQLite into your project and building on top of that. To you it seems like a good idea because you've never written a DB app before and the only DB you've ever seen before is SQLite. You'll get a prototype real fast but you'll never build a PostgreSQL equivalent because you never learned the foundational knowledge of how a DB works and because SQLite forecloses all the pathways you need to get there.
Same thing.
It looks like an open source project. Makes a hell of a lot more sense to implement using that than rolling your own? If it's missing something you need, write it for them.
Writing your own implementation is extremely unlikely to differentiate your app/product. There is a spec, either you implement it and it works, or you don't and it doesn't. Using a maintained library is by far the better option.
Focus your time on the product you are building not the tech.
Because you don’t use Typescript/JS perhaps?
Holy wall of text, Batman!
The fediverse—a decentralized social web powered by protocols like ActivityPub—is an exciting space to explore. If you're considering building the next great federated app, connected to platforms like Mastodon, Lemmy, Pixelfed, and more, you might be tempted to implement ActivityPub from scratch. While this approach offers total control, it’s a daunting task due to the complexity of the standards involved.
At its core, ActivityPub relies on ActivityStreams 2.0 vocabulary and JSON-LD syntax. This combination introduces significant complexity:
Note
or Article
, profiles as Person
or Organization
, and actions like Create
, Follow
, Like
, Announce
) using the precise terms defined in the specification.json
// No name property { "@context": "https://www.w3.org/ns/activitystreams", "type": "Note", "content": "…"} // Equivalent to: { "@context": "https://www.w3.org/ns/activitystreams", "type": "Note", "name": [], "content": "…"}
json
// Single value { "@context": "https://www.w3.org/ns/activitystreams", "type": "Note", "content": "Hello"} // Equivalent to: { "@context": "https://www.w3.org/ns/activitystreams", "type": "Note", "content": ["Hello"]}
json
// Embedded object { "@context": "https://www.w3.org/ns/activitystreams", "type": "Announce", "actor": { "type": "Person", "id": "http://sally.example.org/", "name": "Sally" }, "object": { "type": "Arrive", "id": "https://sally.example.com/arrive", /* ... */ } } // Equivalent to: { "@context": "https://www.w3.org/ns/activitystreams", "type": "Announce", "actor": "http://sally.example.org/", "object": "https://sally.example.com/arrive" }
Fedify, a TypeScript framework, abstracts the complexity of ActivityPub development. It handles the heavy lifting, allowing you to focus on what makes your app unique.
Fedify simplifies federation logic:
typescript
// Handle follow federation.on(Follow, async (ctx, follow) => { // Implement follow logic }); // Handle post activity federation.on(Create, async (ctx, activity) => { // Implement post activity logic });
When running your app:
plaintext
Web interface available at: http://localhost:8000/
Logs example:
plaintext
.lhr.life/r/2 | ╰─────────────────┴───────────────────────────────────────╯
Building a federated app with ActivityPub is challenging, but tools like Fedify make the process manageable. By abstracting away the complexity of JSON-LD and ActivityStreams, Fedify allows developers to focus on creating innovative applications for the fediverse.