# Dovetail > Real-time and offline sync for Ember. The server pushes JSON:API documents into the > WarpDrive store. Local writes are optimistic, and an IndexedDB queue keeps them while the > client is offline. Tiptap documents co-edit through a pluggable CRDT engine (Yjs, Loro or > Automerge), with presence components and notifications (toasts, an inbox, activity feeds). Install `@dovetail-ts/core`, `@dovetail-ts/ember`, `@dovetail-ts/warp-drive` and a transport (`@dovetail-ts/transport-ws`, `@dovetail-ts/transport-sse` or `@dovetail-ts/transport-cable`), and `@ember-joinery/ember` for the tokens. Add `@dovetail-ts/notifications` for toasts and the inbox, and `@dovetail-ts/tiptap` with an engine (`@dovetail-ts/crdt-yjs`, `@dovetail-ts/crdt-loro` or `@dovetail-ts/crdt-automerge`) to co-edit. The servers are `@dovetail-ts/server` (Node) and the gems `dovetail` and `dovetail-rails` (Rails). The hosted adapters are `@dovetail-ts/hocuspocus`, `@dovetail-ts/liveblocks`, `@dovetail-ts/partykit`, and `@dovetail-ts/supabase`. A Neon adapter comes in 1.1; it is not on npm in 1.0. Guide: https://joegaudet.com/dovetail/guide/ Stories: https://joegaudet.com/dovetail/stories/ Live demo: https://joegaudet.com/dovetail/demo/#/demo Source: https://github.com/joegaudet/dovetail ## Rules for writing code with Dovetail 1. Call `configure()` of the `dovetail` service one time, for example in the application route. Give it `transport`, `user`, `getToken` and `sink: storeSink(store)`. `getToken` is necessary when the server has `authenticate`, unless the server sets `allowAnonymous`. 2. Write through `dovetail.write(room, op)`, not through the store. Then the write is optimistic, and it waits in the queue while the client is offline. 3. For a room with a document, call `dovetail.doc()` before `dovetail.presence()`, or use ``. Then the room has one awareness. 4. Turn off the undo of Tiptap StarterKit (`undoRedo: false`). The CRDT has its own undo. 5. Check `capabilities` of the engine before you show a feature. Automerge has no Tiptap binding. 6. On the server, implement `authenticate(token)` and `authorize(user, room, action)`. The server refuses a blank token before `authenticate`. Keep a digest of each token and compare it in constant time. `authorize` allows only when it returns `true`, and a doc edit needs `'write'`. Never trust a write of a client: check it in `handleWrite`, and skip a resend with the write `id`. Check doc updates with `validateUpdate`. 7. Presence names, colors and avatars are client data. Only `user.id` comes from the server. Give each user a `#rrggbb` color and an absolute `https:` avatar URL. The client accepts a remote color only when `isHexColor` of `@dovetail-ts/core` accepts it (`#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`). The Yjs carets of Tiptap accept only `#rrggbb`. 8. A notification goes only to the per-user room (`user:`). Send it with `server.notify`. The inbox sends a mark read or an archive as a partial notification with only the time that changes (`readAt` or `archivedAt`). 9. When the `ack` of a join has `reset: true`, the client must load the records of the room again. Give the sync client `reload: room => Promise<{ documents, complete? }>` (in Ember: `configure({ sync: { reload } })`). `connection.onReset(room, fn)` is the lower-level hook. 10. The memory stores of the servers are for development and tests only. On Rails, give `broadcasts_dovetail` an `attributes:` allowlist. 11. Read the security page of the guide before production: https://joegaudet.com/dovetail/guide/servers/security.md 12. Test components with the harnesses of `@dovetail-ts/test-support` and the `@harnessed-ts/should` matchers. Use `FakeHub` and `FakeClock` for the transport and time.