Imagine a project management app where every delete asks, "Are you sure you want to delete this item?" Users see that dialog twenty times a day. One afternoon, someone deletes the wrong project, clicks "Yes" out of habit, and the project is gone. The dialog was there. It didn't help.
Confirmation dialogs feel safe to build, but they mostly protect the developer's conscience. Undo protects the user.
The short version:
- Make common actions reversible, and let users undo them instead of confirming them.
- Keep confirmation dialogs for rare, destructive actions that genuinely can't be undone.
- Keep the undo window on the server, with an expiry, not in a browser timer.
- Hold side effects like emails, webhooks, and payment captures until the window closes.
- Give the undo option an accessible, persistent path, not just a toast that disappears.
Why confirmation dialogs stop working
The Nielsen Norman Group's article on confirmation dialogs is blunt: don't use them for routine actions. When a dialog appears every time, users learn to dismiss it without reading. The article describes users who simply click "Yes" without thinking, and notes that such automatic behavior provides no protection at all.
Aza Raskin made the same argument in A List Apart in 2007, in an article titled Never Use a Warning When You Mean Undo. People form habits, and a warning that appears every time becomes part of the habit.
Undo fits a broader principle. One of Nielsen's 10 usability heuristics, user control and freedom, says people need a clearly marked emergency exit when they do something by mistake. NN/g's article on user control and freedom puts it directly: support undo and redo.
Undo, confirmation, or both
Undo doesn't replace every confirmation. A useful way to decide is to weigh three things:
- How often the action happens. Frequent actions build habits, so confirmations stop working. Favor undo.
- Whether it can be reversed. If the system can put things back, offer undo. If it can't, confirmation is the remaining safeguard.
- How bad a mistake would be. Archiving an email is minor. Deleting a whole workspace or transferring money is not.
Apple's Human Interface Guidelines on alerts land in the same place. They advise against showing alerts for common, undoable actions, even destructive ones, and reserve alerts for uncommon destructive actions that can't be undone.
In practice:
- Common and reversible: undo, no confirmation. Deleting a comment, archiving a task, removing a file into a trash.
- Rare and irreversible: confirmation, and make it meaningful. Name the thing being deleted and its consequences. For the most severe actions, some products ask users to type the item's name, which breaks the habit of clicking through.
- Rare, severe, and reversible for a while: both. Confirm the intent, then still allow a recovery period.
Two ways to build undo
There are two basic designs, and they behave differently.
Delay the action. Nothing happens until the undo window closes. Gmail's Undo Send is the best-known example. Google's help page lets users choose a cancellation period of 5, 10, 20, or 30 seconds. If the user clicks Undo, the email is never sent.
- Good for actions with side effects you can't take back.
- The action isn't really done until the window ends, so other users and systems don't see it yet.
Do the action, and keep a way back. The change happens immediately, but it's stored in a reversible form: a soft-deleted row, an archived flag, a previous version. Undo restores it.
- The rest of the app sees the change right away.
- Restoring has to handle anything that happened since, such as related records or other users' edits.
- Data stays around longer, which needs a cleanup plan.
Many apps combine them: a quick undo toast for the next few seconds, backed by a trash or history page where items can be restored for days.
Keep the pending state on the server
A common tutorial approach waits in the browser: show the toast, start a setTimeout, and call the API when it fires. That breaks in obvious ways. If the user closes the tab or loses their connection during the window, the action never happens, even though the user believes it did. Two tabs can also disagree about what's pending.
Put the pending state on the server instead:
- For delayed actions, record the pending action with an expiry time, or schedule a background job to run when the window ends. BullMQ's delayed jobs take a delay in milliseconds, and the docs describe it as a minimum, not an exact time. Give the job a predictable job ID, such as the action's ID, so undo can find it. BullMQ ignores a second job with the same ID while the first exists, and IDs can't contain colons or be purely numeric.
- To cancel, remove the job. The Queue API documents that
remove()returns 1 on success and 0 if the job is locked, which happens when a worker has already started it. Treat 0 as "too late to undo." BullMQ's documentation on removing jobs covers the details; test cancelling a delayed job in your own setup before relying on it. - For immediate actions with a reversal, store when the action happened and when its undo window expires, and refuse undo after that.
The server is the only place that knows whether undo is still possible, so it should decide.
Side effects you can't take back
Some things leave your system the moment they happen:
- An email or SMS that has been sent.
- A webhook delivered to a customer's endpoint.
- A call to a third-party API that creates something on their side.
- A captured payment.
You can't undo these, but you can delay them. If deleting an account sends a goodbye email, don't send it until the undo window has closed. The transactional outbox pattern records side effects in the same database transaction as the change; adding a "not before" time to those records, or publishing them as delayed jobs, holds them until undo is no longer possible. If the user undoes the action, cancel the pending side effects with it.
Payments need special care, because a refund is not an undo. Stripe's refunds documentation explains that the processing fees from the original payment aren't returned, that a refund can take several business days to appear for the customer, and that refunds can fail. Cancelling a payment before it completes is a different and cleaner operation.
If your product needs a window in which an order can be called off, Stripe supports placing a hold: authorize the card now, with capture_method set to manual, and capture the funds later. To call it off, you cancel the payment instead of refunding it. As of November 2026, Stripe says an authorization for an online card payment is usually valid for seven days, with shorter windows in some cases, and not every payment method supports separate capture. Check the current limits for the methods you accept.
The undo endpoint
Undo is an API call like any other, and it should be predictable:
- Make it idempotent. Double clicks and retries happen. Undoing something that's already been undone should return success, not an error or a second reversal.
- Say clearly when it's too late. RFC 9110 defines 409 Conflict for requests that conflict with the current state of the resource, which fits an undo after the action has already run. 410 Gone signals that something is no longer available and likely won't be again. Return a machine-readable reason so the UI can explain what happened.
- Protect against overwriting newer changes. If someone edited the item after the original action, restoring an old version could erase their work. Including a version in an
If-Matchheader lets the server reject the undo with 412 Precondition Failed when the item has changed. - Record it. An audit trail that shows the action and its undo helps support teams answer "where did my project go?"
How long should the undo window be?
There's no universal number. Gmail lets users choose between 5 and 30 seconds for sending email. A short window suits a toast; a longer recovery period suits a trash or history page.
Accessibility shapes this decision. WCAG 2.2 success criterion 2.2.1, Timing Adjustable, says that when content has a time limit, users must be able to turn it off, adjust it, or extend it, with some exceptions. W3C's explanation treats something that changes automatically after a set time as a time limit. An undo toast that vanishes after five seconds is a time limit for someone who needs longer to read it or reach it with a keyboard or switch device.
The practical answer is not to make the toast the only way back:
- Keep the toast visible until the user dismisses it or moves on, rather than on a short timer.
- Also offer a persistent path, such as a trash, an activity history, or an undo command in a menu, so the time limit on the toast isn't the only route.
Platform guidance is moving in this direction. Flutter's 3.38 release notes changed snackbars that contain an action so they stay on screen until the user interacts with them, which Flutter says aligns with the Material 3 specification.
For legal, financial, and data-changing submissions, WCAG's Error Prevention criterion lists reversibility as one of three accepted ways to prevent errors, alongside checking input and asking for confirmation. A stated period during which a request can be changed or cancelled is one of its documented techniques.
Accessible undo
An undo toast is a status message, and it needs to be announced without disrupting the user:
- Announce it as a status. WCAG's Status Messages criterion requires that status messages can be presented to users by assistive technology without receiving focus. Use
role="status"for "Item deleted. Undo." The W3C guidance notes that using an alert role for messages that aren't urgent is a failure of this criterion. - Don't move focus to the toast automatically. Focus jumping away from where the user was working is disorienting. Make the Undo button reachable by keyboard instead, and consider a keyboard shortcut.
- Return focus after undo. When the item comes back, put focus on it or on a sensible nearby element.
- Keep it visible long enough, as above. The ARIA alert pattern also advises that alerts shouldn't disappear automatically.
Many tabs and many users
Undo gets harder when others are involved:
- Another tab. If the action is pending on the server, every tab can show the same state. Tabs that cache their own lists should refresh after an undo.
- Another user. If a colleague edits an item while it's in its undo window, restoring an older version could undo their work too. Version checks make the conflict visible, and the UI can explain it instead of silently overwriting.
- Dependent changes. Restoring a deleted project may need its tasks, files, and permissions to come back with it. Decide what the restore covers, and test it.
Retention and erasure
Soft deletes and trash folders keep data around after users think it's gone. For short undo windows, that's usually unremarkable. For longer recovery periods, plan the cleanup. A scheduled job should permanently remove items once their recovery period ends.
For EU users there's another reason to be clear about this. Article 17 of the GDPR, the right to erasure, requires personal data to be erased without undue delay when a valid request is made. A user who asks for their data to be erased is different from a user who clicked Delete on a comment. Make sure your trash and undo design doesn't keep data that a valid erasure request requires you to remove, and check your retention periods with whoever handles compliance.
Checklist
- Replace routine confirmations with undo.
- Keep confirmations for rare, irreversible, high-impact actions, and make them specific.
- Choose delayed execution or a reversible action, and know the trade-offs.
- Store the pending state on the server with an expiry, not in a browser timer.
- Use predictable job IDs if you delay actions with a queue, and treat a failed removal as too late.
- Hold emails, webhooks, and external calls until the undo window closes.
- Use authorize-then-capture for payments that need a cancellation window.
- Make the undo endpoint idempotent, with clear 409 or 410 responses and version checks.
- Don't rely on a disappearing toast alone; offer a trash or history.
- Announce undo with a status role, keep focus where it is, and make Undo keyboard-reachable.
- Handle edits by others during the undo window.
- Purge soft-deleted data on schedule, and respect erasure requests.



