Toaster

Persistent toast stack for session flash, Turbo Streams and JavaScript notifications

View documentation

Mount it once

Conceptual

This playground already mounts the viewport in its layout, which is why every button below can raise a toast without one on the page. A second viewport would fight the first over window.toaster, so the setup is shown rather than rendered.

Once, in the layout

One tag before </body> is the whole setup.

Survives navigation

It ships data-turbo-permanent, so the stack outlives a Drive visit.

Order does not matter

A toast fired before it connects is buffered and drained on connect.

From a session flash

The viewport reads the session itself. toast, success, error, warning, info and errors are read in that order and the first usable message wins — so a failed validation surfaces its first error with no extra wiring.

From a Turbo Stream

turbo_stream()->toast() takes the same arguments as the redirect macro, so both branches of a controller read alike. The stream targets the viewport id.

From JavaScript

The controller publishes the manager as window.toaster on connect — nothing to import. duration: 0 keeps a toast until it is dismissed, and visible-toasts (3 by default) decides how many stay uncollapsed.

Viewport props

Conceptual

Every prop shown at its default. position reads as physical side then logical alignment, so bottom-end follows the document's writing direction.

These configure the viewport in your layout, not individual toasts. A toast can still override position and duration per call.