Giter Site home page Giter Site logo

chwzr / y-sweet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamsocket/y-sweet

0.0 0.0 0.0 1.19 MB

A standalone yjs server with persistence to S3 or filesystem.

Home Page: https://docs.y-sweet.dev

License: Other

Shell 0.49% JavaScript 1.61% Rust 60.25% TypeScript 37.52% CSS 0.03% Dockerfile 0.10%

y-sweet's Introduction

y-sweet: a Yjs server with persistence and auth

GitHub Repo stars Chat on Discord

y-sweet is an open-source server for building realtime applications on top of the Yjs CRDT library.

Features

  • Persists document data to a network filesystem or S3-compatible storage, inspired by Figma’s infrastructure.
  • Scales horizontally with a session backend model.
  • Deploys as a native Linux process, or as a WebAssembly module on Cloudflare's edge.
  • Provides document-level access control via client tokens.
  • Written in Rust with a focus on stability and performance, building on the blazing fast y-crdt library.

y-sweet stack

The y-sweet server can be used by any Yjs app, or you can use our opinionated stack to integrate Yjs and y-sweet into a Next.js app.

  • @y-sweet/sdk, a TypeScript library for interacting with y-sweet-server from your application backend.
  • @y-sweet/react, a React hooks library for building Yjs applications.
  • A debugger for exploring Yjs document and presence state.

The goal of the y-sweet stack is to give developers the end-to-end developer ergonomics they would expect from a proprietary state-sync platform, without the lock-in.

y-sweet is MIT-licensed, and was created by Drifting in Space.

Docs

Examples

Explore our collaborative examples to help you get started.

All examples are open source and live in this repository, within /examples.

Usage

Check the vanilla js example for more details.

On the server

import { DocumentManager } from '@y-sweet/sdk'

// Pass in a CONNECTION_STRING, which you can get from running npx y-sweet@latest serve locally or from y-sweet cloud
const manager = new DocumentManager(CONNECTION_STRING)

// Get the client token from the y-sweet server. The client token is like the user's "password" to edit the "myDoc123" doc.
const clientToken = await manager.getOrCreateClientAndToken('myDoc123')

On the client

import * as Y from 'yjs';
import { createYjsProvider } from '@y-sweet/client';

// Create the yjs doc and link it to the y-sweet server:
const doc = new Y.Doc();
createYjsProvider(doc, clientToken);

// Now use the doc like a normal yjs doc!
let mySharedMap = doc.getMap('thing');
mySharedMap.set("foo", 123);

// Update your UI based on `mySharedMap` changes like this, for example:
mySharedMap.observe((event) => {
  event.keysChanged.forEach((key) => {
    // do whatever you want based on the detected change:
    yourUpdateFunction(key, mySharedMap.get(key));
  });
});

Packages

Server

Package Manager Name Version Path
npm y-sweet npm js-pkg/server
crates.io y-sweet crates.io crates/y-sweet
crates.io y-sweet-core crates.io crates/y-sweet-core

Client

Package Manager Name Version Path
npm @y-sweet/sdk npm js-pkg/sdk
npm @y-sweet/react npm js-pkg/react

Y-Sweet Cloud

If you were to use the open source y-sweet server alone, you would still have to set up the infrastructure for self hosting it. With Y-Sweet cloud, every document is automatically persisted. You can link your own S3-compatible storage, or just let us take care of the details.

You can try a preview for free today by following our quickstart guide.

If you are interested in being a build partner for early access to new features, please reach out.

We are committed to growing y-sweet as an open-source-first project, wherever you decide to host it.

y-sweet's People

Contributors

paulgb avatar rolyatmax avatar feliciachang avatar pretentious7 avatar gentle avatar zwily avatar jakelazaroff avatar savaki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.