Migrate react-ditto to Ditto v5#94
Merged
Aaron Leopold (aaronleopold) merged 9 commits intoJun 9, 2026
Merged
Conversation
v5 drops the query builder and the Identity types, so the old query-builder and identity hooks had to go. In their place are two DQL hooks, useQuery and useExecuteQuery, taken from the stale DQL PR and brought up to the v5 API. Providers now open instances with Ditto.open/DittoConfig and key them off the configured persistence directory. Also reworked the vite example for the v5 init and auth flow, switched its tests from jest to vitest, and refreshed the README, CHANGELOG and CI.
CI was dying because headless Chrome won't start without --no-sandbox on the runners, so the karma launcher passes it now. Review follow-ups: useExecuteQuery leaves items/mutatedDocumentIDs undefined instead of using a null sentinel (matches how TanStack and similar libs behave), dropped the doc-only type imports that only existed to satisfy eslint-disable lines, and pointed the README at support@ditto.com.
These imports back the {@link} references in the JSDoc, and the no-unused-vars
disables are what keep eslint quiet about them. Putting them back the way they
were.
The example opened both instances on load, so the placeholder server config threw validation/invalid-ditto-config and took down the whole app. Now it runs offline out of the box and only spins up the server instance once real portal credentials are filled in.
v5 renamed App ID to Database ID, so the docs and example now talk about creating a database in the portal and grabbing its settings, rather than an app. Left the genuine 'app' references (your React app, the example app) alone.
useQuery and useRemotePeers can hand back a null ditto, and useExecuteQuery an undefined one, before anything has loaded; storeObserver is undefined until the query is configured. The return types now reflect that instead of pretending the values are always present. Also rebuild useQuery's reset when localOnly changes so the sync subscription tracks the flag.
Closed
Jonathan Reyes (jreyes33)
approved these changes
Jun 8, 2026
The try/catch reject tests passed silently when execute() didn't throw. Added expect.fail() after the await (rethrowing the assertion through the catch). That surfaced that the lazy 'invalid instance' test never actually rejected — the wrapper created an instance for any path — so it now uses a setup that returns null to genuinely exercise the rejection path.
So the query result type flows end-to-end instead of degrading to any internally.
Ruben Cristea (rcristea)
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR supersedes #65
v5 drops the query builder and the
*Identitytypes, so the old query-builder and identity hooks had to go. In their place are two DQL hooks,useQueryanduseExecuteQuery, taken from #65 and brought up to the v5 API. Providers now open instances with Ditto.open/DittoConfig and key them off the configured persistence directory.Also reworked the vite example for the v5 init and auth flow, switched its tests from jest to vitest, and refreshed the README, CHANGELOG, CI, etc.