Hathora: Multiplayer Made Easy
Tags: webdev, javascript, programming, gamedev
Published: 2022-04-19 16:21:16

More multiplayer games are being developed than ever before, but building & launching a successful online multiplayer game remains one of the most notoriously difficult endeavors in the software world. The biggest challenges developers face are (1) choosing and correctly implementing the technologies to enable multiplayer, and (2) ending up with an architecture that you can operate and scale.

If you are starting a new game from scratch, you are inundated by a multitude of choices:

- _How should I set up my project structure?_
- _Should I use peer-to-peer or client-server architecture?_
- _TCP, UDP, WebSockets, or WebRTC for networking?_
- _How should I implement authentication?_
- _How do I persist data?_

For the amount of demand for multiplayer games, the development process should not be as hard as it is today. Armed with a passion for multiplayer games and extensive experience building & operating scalable systems, we have been working on a solution. Enter [Hathora](https://hathora.dev/): a framework for building multiplayer games.

Hathora can be used for:

1. 🎲 Turn-based multiplayer games - Examples: Chess, Words with Friends, Codenames, etc
2. 🎮 Realtime multiplayer games - Examples: Among Us, Agar.io, Slither.io, etc
3. 💬 Realtime & social applications - Examples: chat apps, delivery tracking apps, etc

We've built Hathora to provide the most streamlined development experience when starting a multiplayer game from scratch. The framework provides the right abstractions such that a game can be prototyped in minutes and scaled to millions of users.

---

# Prototype in Minutes

Hathora's philosophy is to minimize the burden on the developer by allowing them to focus only on functionality specific to their game, while the framework serves as the engine to power the remaining machinery. We are pushing the limits of game development to drastically reduce the time it takes to ship a game.

## Autogenerate type-safe data model and clients

All Hathora projects start by defining their API using Hathora's language agnostic declarative [API format](https://docs.hathora.dev/#/hathora-yml). From this definition, Hathora generates typesafe data models and clients for the language of your choice.

_Hathora frees you from the extensive boilerplate normally required for client/server applications._


![Hathora codegen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxks7t20pyatl7t25t7z.png)

## Write server logic in 20-100x fewer lines of code

Write backend logic seamlessly in the language of your choice. Just read and update in memory state, no database queries or ORMs needed – _Hathora automatically manages [persistence](https://docs.hathora.dev/#/state?id=persistence) behind the scenes_.

![Hathora backend logic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ttqtgwf9r50tojk6tkfc.png)

## Iterate faster with the Prototype UI

Test your backend logic without writing any frontend code using the built in [Prototype UI](https://docs.hathora.dev/#/type-driven-development?id=prototype-ui). Create & join rooms, call server methods, and interact with live data all from within your browser.

_Hathora enables play testing from the first minute._


![Hathora Prototype UI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8c75pcxfulnackd4tn6v.gif)

## Flexible, cross-platform client support

Once the backend functionality has been verified, it’s easy to use the generated client to [build your UI](https://docs.hathora.dev/#/client?id=fully-custom-frontend) in your platform and technologies of choice and share the game with the world.

_The Hathora client fully handles networking, and easily integrates into any frontend technology/platform of your choice._


![Hathora custom UI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0vozwzyfmd6zbia52wt.gif)


Other features you get out of the box with Hathora:

- Automatic [state synchronization](https://docs.hathora.dev/#/data-flow)
- Optimized [networking](https://docs.hathora.dev/#/networking) (binary protocol, delta encoding)
- Built in [authentication](https://docs.hathora.dev/#/auth)
- Project structure generation & development server with hot reloading

---

# Scale to Millions

Once you've built & released your game, you don't want to spend the next 6 months battling scaling issues and reworking the architecture to meet your user demand. Hathora includes several key components that make it so you can be production-ready from day 1.

## Hathora Coordinator

Central to the Hathora architecture is the managed Coordinator service, which sits between Hathora clients and Hathora backends.


![Hathora coordinator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aceffybqevznfbvjzq4z.png)

The coordinator plays several key roles in the architecture:

1. It ensures consistent routing so that clients playing the same game get routed to the same backend instance.
2. It load balances games between backend instances to ensure an even distribution of traffic.
3. It reduces latency by dynamically assigning games to instances based on the geographic distribution of the connecting users.
4. It handles backend failover by automatically migrating the games from the failed instance to a new instance, all of which is transparent to clients.

## Hathora Protocol

The Hathora Protocol governs the communication between clients and servers. It is flexible, lightweight, platform & transport agnostic.

At the core of the protocol lies a highly optimized serialization format. All data is binary encoded and servers send only delta updates to clients after the initial snapshot. The encoding/decoding code is generated from the API definition and is incredibly efficient so as to minimize latency while sending and receiving messages.

## Hathora Cloud

Although it will always remain possible to self host your backend instances, for those who do not wish to manage their own infrastructure we have built Hathora Cloud.

Hathora Cloud is a platform for running Hathora applications at scale. It has features like autoscaling, multi-region deployments, monitoring & analytics, and migration management. Hathora Cloud makes it simple to deploy your game servers globally and scale to millions of users.

Hathora Cloud is currently in private alpha, sign up using [this form](https://docs.google.com/forms/d/e/1FAIpQLSeGhyNzKozcxNj4zgxi0w3mxup58752JBqCum63-HuHX7X30Q/viewform).

---

[Get started with Hathora today.](https://docs.hathora.dev/#/)