Y-Sweet and Your App
A minimum viable app with Y-Sweet just needs these three components:
- A server that makes HTTP requests to the Y-Sweet API
- A client that connects to the Y-Sweet server
- A Y-Sweet server, which syncs data across users with Yjs and persists your data in blob storage.
You may have additional components to your stack, like a database for saving user and document metadata. But for most collaborative realtime applications that don't require authentication, a Y-Sweet app that follows this structure is all you need.
If you're building with Nextjs, your server and client will
client will refer to the server-side and client-side of the same Nextjs codebase.
Check out the following tutorials for how to setup and build a realtime, collaborative app with Y-Sweet.
Y-sweet speaks to both your client and server to serve your users realtime collaborative documents. It can be helpful to know how y-sweet interacts with the client and server. Here's the breakdown:
When your user opens a document...
- Your server will make an authenticated request to the Y-Sweet API using
getClientToken. Both these functions require a
connection stringto authenticate your request.
getClientTokenwill return a
- Your client will use this
client tokento connect to the Y-Sweet server via a websocket connection that's managed on the client-side by
- When your users make changes to a document, the Y-Sweet server will register those changes, resolve conflicts, and persist your data. This means that users returning to the document will always see the latest changes.