refrakt/flash

Flash message helpers built on signed cookies.

Flash messages are short-lived messages shown once after a redirect. They are stored as signed cookies and cleared after reading.

Example

// In a handler, after creating a post:
wisp.redirect("/posts")
|> flash.set_flash(req, "info", "Post created")

// In a layout or component:
let message = flash.get_flash(req, "info")

Values

pub fn get_flash(
  req: request.Request(wisp.Connection),
  key: String,
) -> Result(String, Nil)

Read a flash message from a request. Returns the message if present.

pub fn set_flash(
  response: response.Response(wisp.Body),
  req: request.Request(wisp.Connection),
  key: String,
  message: String,
) -> response.Response(wisp.Body)

Set a flash message on a response. Uses signed cookies with a short TTL.

✨ Search Document