Synchronize data to your clients in real time with websockets. Deploy on your own infrastructure!
To deploy your own Sinkr instance, follow these steps:
- Clone this repository
- Run
pnpm install
in the root directory - In Cloudflare, ensure you have a domain you want to deploy to.
- In GitHub, create a new GitHub OAuth app
- Make sure the app has the callback URL set to
<your domain>/api/auth/callback/github
- Save your client ID and secret
- Make sure the app has the callback URL set to
- Setup your Cloudflare workers
- Run
cd apps/app-manager
- Run
pnpm wrangler login
to authenticate Wrangler - Run
pnpm wrangler d1 create <your-database-name>
to create a D1 database. - Copy
wrangler.example.toml
intowrangler.toml
and fill out the values with your created bindings for bothapp-manager
anddeployment
- Both should use the same
D1
database binding (ID and name) - Each one should use a separate domain. For example,
apps.example.com
andws.example.com
forapp-manager
anddeployment
- Both should use the same
- Run
pnpm wrangler d1 execute <your-database-name> --file setup.sql --remote
and confirm. - Add the following environment variables to a
.env
file:CLOUDFLARE_ACCOUNT_ID
: your Cloudflare account IDCLOUDFLARE_DATABASE_ID
: the Database ID of your D1 databasaeCLOUDFLARE_D1_TOKEN
: the API token created in step 4
- Update
apps/app-manager/src/server/auth.ts:32
to add your own GitHub login as an administrator - Add the following Cloudflare secrets:
- Run
pnpm wrangler secret put AUTH_SECRET
- Paste a random, securely generated string of characters. I recommend using
openssl rand -base64 32
- Run
pnpm wrangler secret put AUTH_GITHUB_ID
- Paste your GitHub OAuth client ID from the app created in step 3
- Run
pnpm wrangler secret put AUTH_GITHUB_SECRET
- Paste your GitHub OAuth client secret from the app created in step 3
- Run
pnpm run deploy
to deploy your App Manager - Run
cd ../deployment
- Run
pnpm run deploy
to deploy your Websocket manager - Link your app manager and worker to your domain.
- Make sure the subdomain you choose for your app manager matches the url you put into GitHub
- Run
- Install the SDK in your app code
- For TypeScript apps of any kind, simply install
@sinkr/core
from JSR. - For React apps, install
@sinkr/react
from JSR. This also exports@sinkr/core
so installing both is not strictly necessary. - For Python apps of any kind, install
sinkr
from PyPI
- For TypeScript apps of any kind, simply install
- Done! Start sending and receiving messages!