Use data-turbo-action to control history (advance vs replace)

7190
0

Turbo Drive records visits in browser history. For some interactions (like typing through search results), you don’t want every click to create a new history entry. Turbo supports data-turbo-action='replace' to replace the current history entry instead of advancing. This is especially useful for “pick something quickly” flows: filters, tabs, and list-detail frames. I pair this with predictable URLs so refresh still works. The mental model is: advance when navigation is meaningful, replace when the visit is more like a UI state change. It’s a tiny attribute but it dramatically improves back-button behavior. I also use it on “sort” links to avoid back-button spam.