A big difference between Tanstack Query and Tanstack DB: Tanstack Query is...


A big difference between Tanstack Query and Tanstack DB:

Tanstack Query is pessimistic by default. It updates the UI *after* an async write completes. Safe, but slow.

Tanstack DB is optimistic by default. It updates the UI *before* the async write completes. Risky, but fast.

in Tanstack Query, optimistic UI is possible, but requires a *lot* of boilerplate.

In Tanstack DB, optimistic UI is automatic, and failures roll the UI back to the previous value.

Oh, and Tanstack DB makes pessimistic UI easy.

You await the transaction like this. So just one extra line of code to wait.

View original on X