[GH-ISSUE #349] optimistic update #16861

Closed
opened 2026-04-15 14:50:53 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @darklight9811 on GitHub (Oct 26, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/349

Is your feature request related to a problem? Please describe.
When you logout (using react), you wait for the request to finish to update the UI. It would be better for the user experience if we removed the cookies and already updated the ui.

Describe the solution you'd like
Don't wait for the logout request to the backend to happen, update the UI before that happens.

Describe alternatives you've considered
none

Originally created by @darklight9811 on GitHub (Oct 26, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/349 **Is your feature request related to a problem? Please describe.** When you logout (using react), you wait for the request to finish to update the UI. It would be better for the user experience if we removed the cookies and already updated the ui. **Describe the solution you'd like** Don't wait for the logout request to the backend to happen, update the UI before that happens. **Describe alternatives you've considered** none
GiteaMirror added the locked label 2026-04-15 14:50:53 -05:00
Author
Owner

@luksch42 commented on GitHub (Oct 29, 2024):

While optimistic updates are excellent for non-critical actions, logging out is a security-sensitive event. Updating the UI before confirming the logout could lead to misunderstandings if the session isn't properly terminated on the server side. To ensure user security, imo it's best to update the UI only after the backend confirms the logout.

If you still need optimistic updates, you could implement that directly in your frontend.

<!-- gh-comment-id:2445209114 --> @luksch42 commented on GitHub (Oct 29, 2024): While optimistic updates are excellent for non-critical actions, logging out is a security-sensitive event. Updating the UI before confirming the logout could lead to misunderstandings if the session isn't properly terminated on the server side. To ensure user security, imo it's best to update the UI only after the backend confirms the logout. If you still need optimistic updates, you could implement that directly in your frontend.
Author
Owner

@darklight9811 commented on GitHub (Oct 30, 2024):

@luksch42 how could I do that? the better-auth has the single source of truth for the user and session, are you talking about encapsulating that information so I can do this implementation through it?

<!-- gh-comment-id:2445734136 --> @darklight9811 commented on GitHub (Oct 30, 2024): @luksch42 how could I do that? the better-auth has the single source of truth for the user and session, are you talking about encapsulating that information so I can do this implementation through it?
Author
Owner

@luksch42 commented on GitHub (Oct 30, 2024):

@darklight9811 #365 exposes the client store. You should be able to manipulate the data there. The PR has not been merged yet, but work on it is already in progress.

update: merged in v0.6.3-beta.1 :)

<!-- gh-comment-id:2446075512 --> @luksch42 commented on GitHub (Oct 30, 2024): @darklight9811 #365 exposes the client store. You should be able to manipulate the data there. The PR has not been merged yet, but work on it is already in progress. update: merged in [v0.6.3-beta.1](https://github.com/better-auth/better-auth/releases/tag/v0.6.3-beta.1) :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16861