Toast notifications delivered with Turbo Streams

10079
0

Toasts are a great fit for Turbo Streams because they’re ephemeral UI that doesn’t need a dedicated page. I keep a #toasts container in the layout and turbo_stream.append a toast partial on success events. The toast itself is just HTML with a Stimulus controller to auto-dismiss after a delay. This keeps the server in charge of messaging, and it works for both Turbo and full HTML flows. It also solves the “flash message disappears too quickly” problem: you can show both a flash (for full navigation) and a toast (for in-place actions) without doubling code. I’m careful to keep toast content safe—use plain text or sanitize if it contains user-generated strings.