I imagine datascript is often being used for an offline-first db, and synced back to something more persistent like XTDB. Are there any best practices / guides to something like this?
I am doing exactly this, but would be interested in how other approach it in case I can improve things. currently I store the db in local storage and then submit it over to xtdb creating a new version, but this is reliant on a button the user clicks, I also have to run queries to grab the data and format it to send over the wire as I don't store the whole document in xtdb. But I can answer question about how I am doing it, but I recon there are likely better ways 🙂
On the server, the current best way is https://github.com/tonsky/datascript/blob/master/docs/storage.md#storage-new-hot-best
On the client, yeah, probably tricky
There were a bunch of attempts already with datahike probably the best one. Check out links here in the Datalog resources if something fits your needs: https://github.com/simongray/clojure-graph-resources
But I don't think there is a reliable solution to sync frontend datascript into some persistent storage on server yet.
I did the port of Datahike to cljs but it was a long process and fell too far behind main. Performance also needed work. A lot of work was needed and not enough funds or interest to continue work on it. I still hope it can land one day and would definitely revisit the work on it given the funds to do it because it would be good having Datahike on the front end with sync to a backend.
I use Datascript on the frontend with re-posh and Datomic Ions on the backend. In Datascript I keep the correspondence between Datascript IDs and Datomic IDs . My transactions are sent to Datomic and the resulting transaction is then run locally in Datascript.