DEV Community

Cover image for How to Put Your Blog on the Fediverse
Wade Zimmerman
Wade Zimmerman

Posted on • Updated on

How to Put Your Blog on the Fediverse

History/Why I should care about Mastodon or Fediverse

Recently, there has been an influx of people who want autonomy in social media. People value their privacy and wonder why we must go to,, or to socialize? Why can't we start our own social media?

Only recently, the answer was that building social media is expensive and complicated. However, this is changing thanks to new W3C protocols.

Mastodon takes most of the credit for adopting these new protocols because they built a clone of X (formerly Twitter) that operates in the Fediverse.

How the Fediverse Exists

The Fediverse is a federation of servers that agree to communicate via the ActivityPub (AP) protocol. Like HTTP, SMTP, DNS, etc., the AP protocol specifies how servers should communicate to act as a social media website.

For example, email protocols require all email clients/servers to adhere to a set of rules. Those rules dictate how an email message is sent and received. This makes it possible to send a message from to to without a centralized authority.

Fediverse FAQ

So what does this mean for social media?

It means you can have a username like wadecodez and a custom domain name like, and when the handle makes a post, it will be available to all other platforms. Post once communicate everywhere.

Does My Platform Need to be a Twitter Clone?

No. Anything that follows the ActivityPub specification is valid. It could be your blog, your todo app, or something entirely different.

Then what is Mastodon?

Mastodon is an implementation of the AP protocol that chooses to behave like X (formerly Twitter). Sites that implement the AP protocol are free to exist and act however they want. Sites like and are totally separate ideas, but they can communicate with Mastodon. It is up to your server to respect the content of the other servers.

Do I need to make a Mastodon instance to join the Fediverse?

No. As long as you implement the bare minimum, your blog can be a member of the Fediverse!

How to create the bare minimum to join the fediverse

Choose your language/framework of choice to receive HTTP requests. Python, Ruby, Node, PHP. Then, you'll create endpoints for discovering users, querying user profiles, and returning the contents of the inbox/outbox.

1. Allow for discovery

The rest of the internet needs a way to check if your server is a member of the Fediverse. This is done according to the WebFinger protocol. When the endpoint returns a valid JSON response, other websites can assume your server may support Fediverse activity.

// handles

Route::get('/.well-known/webfinger', function (Request $request) {
    //todo should be dynamic and validated

    $subject = '';
    $handle =  '';
    $username = Str::between($subject, 'acct:', $handle);

    return myJson([
        'subject' => $subject,
        'aliases' => [
        'links' => [
                "rel" => "",
                "type" => "text/html",
                "href" => '',
                'rel' => 'self',
                'type' => 'application/activity+json',
                'href' => '',
Enter fullscreen mode Exit fullscreen mode

2. Query the User's profile

The code above specifies the supports the application/activity+json content type. When the rest of the internet sees this URL, they expect you to return an ActivityPub Person type. See specification

But because most websites expect this Person to be an Actor, we also need to meet the specification for an Actor type:

Route::get('/activityPub/users/{user}', function (Request $request, User $user) {
    return myJson([
       '@context' => '',
       'type' => 'Person',
       'id' => '',
       'name' => 'Test User',
       'preferredUsername' => 'alice123',
       'summary' => 'my favorite food is pizza',
       'inbox' => '',
       'outbox' => '',
Enter fullscreen mode Exit fullscreen mode

3. Return an Empty inbox and Outbox

The last thing to do is to ensure the inbox/outbox contains data. Both boxes are an OrderedCollection. see spec When you go live these endpoints will need to acknowledge incoming POST requests. This means you need to send a POST request back to the initiator of the request.

Route::get('/activityPub/users/{user}/inbox', function (Request $request, User $user) {
    return myJson([
        '@context' => '',
        'summary' => 'Inbox for alice',
        'type' => 'OrderedCollection',
        'totalItems' => 0,
        'orderedItems' => [],

Route::get('/activityPub/users/{user}/outbox', function (Request $request, User $user) {
    return myJson([
        '@context' => '',
        'summary' => 'Outbox for alice',
        'type' => 'OrderedCollection',
        'totalItems' => 0,
        'orderedItems' => [],
Enter fullscreen mode Exit fullscreen mode

You are now in the Fediverse!

When you deploy your app and serve over HTTPS, you should see your profile through sites like Mastodon. You may have to log in to said platform to trigger account discovery.

Proof that it works

Now what?

Implement other parts of the protocol, but do whatever you want. Make a blog, make a todo app, make something exiting and anything that follows the protocol will be visible throughout the Fediverse!

Top comments (0)