Skip to content

Commit b6326c1

Browse files
authored
update README (#300)
1 parent 7d9093a commit b6326c1

File tree

2 files changed

+42
-61
lines changed

2 files changed

+42
-61
lines changed

README.md

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,81 @@
1-
<img src="https://raw.githubusercontent.com/drifting-in-space/y-sweet/main/logo.svg" />
1+
<img src="https://raw.githubusercontent.com/jamsocket/y-sweet/main/logo.svg" />
22

3-
# y-sweet: a Yjs server with persistence and auth
3+
# Y-Sweet: a Yjs server with persistence and auth
44

5-
[![GitHub Repo stars](https://img.shields.io/github/stars/drifting-in-space/y-sweet?style=social)](https://github.com/drifting-in-space/y-sweet)
5+
[![GitHub Repo stars](https://img.shields.io/github/stars/jamsocket/y-sweet?style=social)](https://github.com/jamsocket/y-sweet)
66
[![Chat on Discord](https://img.shields.io/discord/939641163265232947?color=404eed&label=discord)](https://discord.gg/N5sEpsuhh9)
77

8-
**y-sweet** is an open-source server for building realtime applications on top of the [Yjs](https://github.com/yjs/yjs) CRDT library.
8+
**Y-Sweet** is an open-source server for building realtime applications on top of the [Yjs](https://github.com/yjs/yjs) CRDT library.
99

1010
## Features
1111

1212
- Persists document data to a network filesystem or S3-compatible storage, [inspired by Figma’s infrastructure](https://digest.browsertech.com/archive/browsertech-digest-figma-is-a-file-editor/).
1313
- Scales horizontally with a [session backend](https://jamsocket.com/blog/session-backends) model.
14-
- Deploys as a native Linux process, or as a WebAssembly module on Cloudflare's edge.
14+
- Deploys as a native Linux process.
1515
- Provides document-level access control via client tokens.
1616
- Written in Rust with a focus on stability and performance, building on the [blazing fast](https://github.com/dmonad/crdt-benchmarks) [y-crdt](https://github.com/y-crdt/y-crdt/) library.
1717

18-
## y-sweet stack
18+
## Y-Sweet stack
1919

20-
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.
20+
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.
2121

2222
- `@y-sweet/sdk`, a TypeScript library for interacting with `y-sweet-server` from your application backend.
23-
- `@y-sweet/react`, a React hooks library for building Yjs applications.
24-
- A [debugger](https://y-sweet.cloud/advanced/debugger) for exploring Yjs document and presence state.
23+
- `@y-sweet/client`, a TypeScript library for syncing documents from a client to a Y-Sweet server.
24+
- `@y-sweet/react`, a library of React hooks for connecting to a Y-Sweet server and manipulating Yjs docs.
25+
- A [debugger](https://docs.jamsocket.com/y-sweet/advanced/debugger) for exploring Yjs document and presence state.
2526

26-
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**.
27+
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**.
2728

28-
y-sweet is MIT-licensed, and was created by [Jamsocket](https://jamsocket.com).
29+
Y-Sweet is MIT-licensed, and was created by [Jamsocket](https://jamsocket.com).
2930

3031
## Docs
3132

3233
- [API docs](https://docs.y-sweet.dev/index.html)
3334
- [Vanilla JS client](https://docs.y-sweet.dev/modules/_y_sweet_client.html)
3435
- [React hooks](https://docs.y-sweet.dev/modules/_y_sweet_react.html)
3536
- [Document management SDK](https://docs.y-sweet.dev/modules/_y_sweet_sdk.html)
36-
- [Y-Sweet Cloud (managed service) docs](https://y-sweet.cloud/quickstart)
37+
- [Y-Sweet Cloud (managed service) docs](https://docs.jamsocket.com/y-sweet/quickstart)
3738
- [Self Hosting](https://github.com/jamsocket/y-sweet/blob/main/docs/running.md)
3839

3940
## Examples
4041

41-
Explore our [collaborative examples](https://github.com/drifting-in-space/y-sweet) to help you get started.
42+
Explore our [collaborative examples](https://github.com/jamsocket/y-sweet) to help you get started.
4243

43-
All examples are open source and live in this repository, within [/examples](https://github.com/drifting-in-space/y-sweet/tree/main/examples).
44+
All examples are open source and live in this repository, within [/examples](https://github.com/jamsocket/y-sweet/tree/main/examples).
4445

4546
## Usage
4647

4748
Check the [vanilla js example](/examples/vanilla/) for more details.
4849

4950
### On the server
5051
``` js
51-
import { DocumentManager } from '@y-sweet/sdk'
52-
53-
// Pass in a CONNECTION_STRING, which you can get from running npx y-sweet@latest serve locally or from y-sweet cloud
54-
const manager = new DocumentManager(CONNECTION_STRING)
55-
56-
// Get the client token from the y-sweet server. The client token is like the user's "password" to edit the "myDoc123" doc.
57-
const clientToken = await manager.getOrCreateDocAndToken('myDoc123')
52+
import { DocumentManager } from '@y-sweet/sdk';
53+
54+
// Pass in a CONNECTION_STRING, which you can get from a Y-Sweet service in the Jamsocket dashboard or from running npx y-sweet@latest serve locally
55+
const manager = new DocumentManager(CONNECTION_STRING);
56+
57+
// create an endpoint that auths your user and returns a Y-Sweet client token
58+
export async function POST(request) {
59+
// in a production app, you'd want to authenticate the user
60+
// and make sure they have access to the given doc
61+
const body = await request.json();
62+
const docId = body.docId;
63+
const clientToken = await manager.getOrCreateDocAndToken(docId);
64+
return Response.json(clientToken);
65+
}
5866
```
5967

6068
### On the client
6169
``` js
6270
import * as Y from 'yjs';
6371
import { createYjsProvider } from '@y-sweet/client';
6472

65-
// Create the yjs doc and link it to the y-sweet server:
73+
// Create the Yjs doc and link it to the Y-Sweet server:
6674
const doc = new Y.Doc();
67-
createYjsProvider(doc, clientToken);
75+
const docId = 'my-doc-id';
76+
createYjsProvider(doc, docId, '/api/my-auth-endpoint');
6877

69-
// Now use the doc like a normal yjs doc!
78+
// Now use the doc like a normal Yjs doc!
7079
let mySharedMap = doc.getMap('thing');
7180
mySharedMap.set("foo", 123);
7281

@@ -98,12 +107,12 @@ mySharedMap.observe((event) => {
98107
| npm | `@y-sweet/react` | [![npm](https://img.shields.io/npm/v/@y-sweet/react)](https://www.npmjs.com/package/@y-sweet/react) | `js-pkg/react` |
99108
| pypi | `y-sweet-sdk` | [![pypi](https://img.shields.io/pypi/v/y-sweet-sdk)](https://pypi.org/project/y-sweet-sdk/) | `python/y_sweet_sdk` |
100109

101-
## Y-Sweet Cloud
110+
## Hosted Y-Sweet on Jamsocket
102111

103-
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.
112+
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 [Jamsocket](https://jamsocket.com/y-sweet), Y-Sweet scales effortlessly, and every document is automatically persisted when you link your own S3 storage.
104113

105-
You can try a preview for free today by following our [quickstart](https://y-sweet.cloud/quickstart) guide.
114+
You can try it out for free today by following our [quickstart](https://docs.jamsocket.com/y-sweet/quickstart) guide.
106115

107116
If you are interested in being a build partner for early access to new features, please [reach out](mailto:[email protected]).
108117

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

docs/running.md

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Running a y-sweet server
1+
# Running a Y-Sweet server
22

3-
The [quickstart](https://y-sweet.dev/quickstart) guide provides instructions for using our hosted y-sweet server, but if you prefer to host it on your own you have several options.
3+
The [quickstart](https://docs.jamsocket.com/y-sweet/quickstart) guide provides instructions for using hosted Y-Sweet on Jamsocket, but if you prefer to host it on your own you have several options.
44

55
## Running a dev server
66

@@ -10,47 +10,19 @@ If you have `npm`, the fastest way to run a local server is with `npx`:
1010
npx y-sweet@latest serve
1111
```
1212

13-
This will download `y-sweet` if you do not already have it, and run it.
13+
This will download the Y-Sweet server if you do not already have it, and run it.
1414

1515
By default, `y-sweet serve` does not write data to disk. You can specify a directory to persist data to, like this:
1616

1717
```bash
1818
npx y-sweet@latest serve /path/to/data
1919
```
2020

21-
If the directory starts with `s3://`, `y-sweet` will treat it as an S3-compatible bucket path. In this case, `y-sweet` will pick up your local AWS credentials from the environment. If you do not have AWS credentials set up, you can set them up with `aws configure`.
21+
If the directory starts with `s3://`, Y-Sweet will treat it as an S3-compatible bucket path. In this case, Y-Sweet will pick up your local AWS credentials from the environment. If you do not have AWS credentials set up, you can set them up with `aws configure`.
2222

2323
## Deploying to Jamsocket
2424

25-
Run the Y-Sweet server on [Jamsocket's session backends](https://jamsocket.com/).
26-
27-
Currently available for early access. If you're interested, [reach out to us](mailto:[email protected]).
28-
29-
## Running a Cloudflare Workers dev server
30-
31-
You can also run a local dev server based on the Cloudflare Workers runtime. This is only recommended for testing changes to the Cloudflare Workers code; if you just want to run a local server, the previous method is preferred.
32-
33-
Running the Cloudflare Worker requires cloning the repo and building it from source:
34-
35-
```bash
36-
git clone https://github.com/drifting-in-space/y-sweet.git
37-
cd y-sweet/crates/y-sweet-worker
38-
npm i
39-
npm run dev
40-
```
41-
42-
## Deploying to Cloudflare
43-
44-
To deploy to Cloudflare, use the `deploy` script:
45-
46-
```bash
47-
git clone https://github.com/drifting-in-space/y-sweet.git
48-
cd y-sweet/crates/y-sweet-worker
49-
npm i
50-
npm run deploy
51-
```
52-
53-
See `y-sweet/crates/y-sweet-worker/wrangler.toml` for the Cloudflare resources it references. You will either need to create these resources or change the configuration to point to your own resources.
25+
Run the Y-Sweet server on [Jamsocket's session backends](https://jamsocket.com/y-sweet). Check out the [quickstart](https://docs.jamsocket.com/y-sweet/quickstart) guide to get up and running in just a few minutes.
5426

5527
## Docker Image
5628

0 commit comments

Comments
 (0)