Y-Sweet: our Yjs Server for Realtime Apps
2024-09-26
Felicia Chang
At Jamsocket, we build infrastructure for WebSocket-powered realtime applications. Many developers building these kinds of applications use a CRDT library called Yjs.
A year ago, we saw a need for a versatile and performant Yjs backend with built-in persistence and auth, so we open-sourced Y-Sweet.
Y-Sweet quickly became a go-to solution for Yjs WebSocket servers. It is loved for having better support, accessible documentation, and different scaling options.
Now, we're making Y-Sweet even easier to spin up by making it available on Jamsocket. We've rolled out Y-Sweet on Jamsocket to select customers. If you'd like early access, please reach out.
In between engineering time, I spoke with Paul, co-founder of Jamsocket, about Y-Sweet and Yjs. Here are some core takeaways from our conversation:
What is Yjs?
Yjs stands out as a leading CRDT library. It provides a simple, JSON-like data structure to represent your application data. As users interact, Yjs synchronizes changes to ensure a smooth, realtime multiplayer experience.
Yjs stands out as the leading CRDT library because it offers many editor bindings like CodeMirror, TipTap and more. While Yjs supports various use cases beyond text, handling text is particularly challenging for CRDTs, making this capability especially important.
How do you deploy Yjs?
At its core, Yjs is a data structure library. While Yjs provides a WebSocket server, setting it up can feel like piecing together a complex puzzle of persistence, networking, and authentication.
Y-Sweet offers a lightweight, out-of-the-box Yjs server that you can run with a simple command. This CLI command installs Y-Sweet and runs it locally in seconds.
What advantages does Y-Sweet offer compared to other Yjs servers?
Y-Sweet was built for simplicity and ease of use. It features a consistent API, no matter how you deploy it—whether as a single-node server, on Cloudflare, or on Jamsocket. Because Y-Sweet has a consistent API, you can change hosting configurations just by changing the Y-Sweet API URL.
The Object Storage Advantage
When documents grow large or when a long tail of documents accumulates over time, object storage offers a cost-effective and scalable solution. It’s also a straightforward and widely supported primitive across all cloud providers.
Y-Sweet leverages object storage for these reasons, allowing flexibility in how the server operates while accessing the same underlying data. You can move from Cloudflare Workers to a single-node process to Jamsocket without a data migration, since the data remains constant throughout.
Scale to the complexity of your app
Despite its simplicity, Y-Sweet scales to the complexity of your application, supporting built-in persistence, networking, and authentication.
In the coming month, we will make Y-Sweet on Jamsocket generally available.
To learn more about Y-Sweet, check it out on Github or play with a Y-Sweet demo.