@slake-dev/sync
v2.1.1
Published
Real-time sync layer for Slake collaborative annotations
Readme
@slake-dev/sync
Client-side SDK for Slake — multiplayer design review on your running builds. Adds collaborative annotations, cursors, and comments to any React app.
Install
npm install @slake-dev/syncWhich entry should I use?
@slake-dev/sync ships two entry points. Pick based on the host's React version:
| Your React | Use | Why | Also install? |
|---|---|---|---|
| 17, 18, 19 | import { SlakeSync } from '@slake-dev/sync' (component path) | Smallest install; shares your React instance | Nothing — @slake-dev/sds installs automatically |
| 16.8 – 16.x | import { mount } from '@slake-dev/sync/standalone' | Component path is compiled with the new JSX transform, which imports react/jsx-runtime (React 17+ only). Standalone bundles its own React. | Nothing — SDS is inlined into the standalone bundle |
| 16.0 – 16.7 | Not supported | Slake uses hooks. Upgrade React to 16.8+, or track #318 for the shadow-root standalone with no React peer dep. | n/a |
| Non-React host | @slake-dev/sync/standalone | Bundles React + everything; mounts imperatively. | Nothing |
npx @slake-dev/cli init reads your React version and installs the right packages + writes the right snippet for you.
Setup
Wrap your app with the Slake provider:
import { SlakeAnnotation } from '@slake-dev/sync';
function App() {
return (
<>
<YourApp />
<SlakeAnnotation
serverUrl="http://localhost:4000"
projectId="my-project"
user={{ id: 'user-1', name: 'Alice' }}
/>
</>
);
}Quick start with the CLI
The easiest way to add Slake to an existing project:
npx @slake-dev/cli initGitHub / GitHub Enterprise
GitHub sign-in (avatars, @mentions, issue creation, agent dispatch) works against public github.com out of the box. To use a GitHub Enterprise host instead, register an OAuth app on that host (Device Flow enabled) and set GITHUB_ENTERPRISE_HOST + GITHUB_ENTERPRISE_CLIENT_ID on the @slake-dev/server backend — Slake auto-detects the host from your git remote and routes sign-in there. Full walkthrough: root README → GitHub Enterprise.
Peer dependencies
react>=16.8.0 <20.0.0react-dom>=16.8.0 <20.0.0
@slake-dev/sds is bundled as a regular dependency, so it installs automatically with @slake-dev/sync. Standalone-path consumers (@slake-dev/sync/standalone) get SDS inlined into the bundle at build time and don't import from node_modules/@slake-dev/sds at runtime — the install cost is paid by both paths but the runtime cost only by the component path.
The React range admits 16.8+ so the standalone entry can install on legacy hosts. The component path requires React 17+ at compile time (it uses the new JSX transform) — see the routing table above for which entry to pick.
