Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alchemy-tinybase-do

A deployable TinyBase sync server as an Alchemy.run resource using Cloudflare Durable Objects.

Installation

npm install alchemy-tinybase-do

Usage

In your alchemy.run.ts file:

import alchemy from 'alchemy';
import { TinybaseDoSync } from 'alchemy-tinybase-do';

const app = alchemy('my-app');

const tinybaseDO = await TinybaseDoSync('tinybase-sync', {
  // If data should be persisted to the Durable Object
  persist: true, // default: false
});

await app.finalize();

Configuration Options

persist (boolean)

  • Default: false
  • When true, data is persisted in the Durable Object storage between client sessions
  • When false, the Durable Object only provides synchronization between clients (clients are expected to persist their own data)

Features

  • Real-time synchronization between multiple clients using WebSockets
  • Optional server-side persistence using Cloudflare Durable Objects
  • Built on TinyBase's mergeable store for conflict-free synchronization
  • Fully typed with TypeScript

Client Integration

Your client applications can connect to the deployed sync server using TinyBase's WebSocket synchronizer:

import { createMergeableStore } from 'tinybase';
import { createWsSynchronizer } from 'tinybase/synchronizers';

const store = createMergeableStore();
const synchronizer = createWsSynchronizer(
  store,
  'wss://your-worker-url.workers.dev'
);

await synchronizer.startSync();

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages