Read about this new project!
Synclets are intended to make it easy to synchronize data between the different parts of your applications, whether between local storage and remote servers, between different devices, or even across worker boundaries.
We believe synchronization is a fundamental part of modern app development, especially in the context of rich client and local-first apps. We also believe that you shouldn't be locked into a specific storage solution, transport layer, or vendor in order to do so!
Synclets are designed to work with lots of different flavors of storage and transport. For example, you can easily connect to a local instance of PGlite.
import {PGlite} from '@electric-sql/pglite';
import {createPgliteDataConnector} from 'synclets/connector/database/pglite';
const db = await PGlite.create();
const dataConnector = createPgliteDataConnector(1, db);You can store metadata about your data (primarily timestamps) separately, or in the same data store. For example, here we're using PGlite for metadata too.
import {createPgliteMetaConnector} from 'synclets/connector/database/pglite';
const metaConnector = createPgliteMetaConnector(1, db);Synclets are designed to work over a variety of transport layers. For example, to use WebSockets via a server use the createWsClientTransport function.
import {createWsClientTransport} from 'synclets/transport/ws';
import {WebSocket} from 'ws';
const transport = createWsClientTransport(
new WebSocket('wss://demo.synclets.org/room1'),
);Finally compose a Synclet instance with your chosen data connector, meta connector, and transport - and start it!
We're good to go.
Take a look at the sample in our launch announcement for a working example.
import {createSynclet} from 'synclets';
const synclet = await createSynclet({
dataConnector,
metaConnector,
transport,
});
await synclet.start();
// ...
await synclet.destroy();The Synclets project is pre-alpha right now, so there is still plenty of work to be done! There are decent test suites in place for the core components, and some basic documentation, but we still need to build out more connectors, transports, and examples.
We hope you like the idea of this project! If so, please follow us on GitHub, X, or BlueSky, and stay tuned for future updates as we continue to develop Synclets further.
Also feel free to kick the tires on our very basic Vite template.
The Synclets project is part of a group of libraries designed to help make rich client and local-first apps easier to build. Check out the others:
TinyBase
A reactive data store and sync engine.
TinyWidgets
A collection of tiny, reusable, UI components.
TinyTick
A tiny but very useful task orchestrator.