Flash Messages

Display temporary notifications after user actions. No external dependencies required.

Usage in a controller
@POST("/login")
public Object login(Request req, Response res) {
    try {
        if (Auth.login(req.queryParams("username"), req.queryParams("password"), req)) {
            return redirectWithSuccess("Welcome back!", "/dashboard");
        }
        return redirectWithError("Invalid credentials", "/login");
    } catch (LoginLockedException e) {
        return redirectWithError(e.getMessage(), "/login");
    }
}
Available types
redirectWithSuccess("Operation completed!", "/");
redirectWithError("Something went wrong",  "/");
redirectWithInfo("Check your email",      "/");
redirectWithWarning("Changes require restart", "/");
Display in layout

Add {{ flash() }} once in your base layout — it renders automatically when a flash message exists.

<body>
    {% block content %}{% endblock %}

    {{ flash() | raw }}
</body>
Custom configuration

Use a @Config class to configure flash notifications at startup. See Config.

@Config
public class NotifConfig implements ConfigInterface {

    @Override
    public void configure() {
        FlashConfig.setDuration(5000);

        // Options: top-right, top-left, bottom-right,
        //          bottom-left, top-center, bottom-center
        FlashConfig.setPosition("top-right");

        FlashConfig.setCustomCSS("""
            .flash-notification {
                border-radius: 1rem;
                font-size: 0.875rem;
            }
            .flash-success {
                background: linear-gradient(to right, #10b981, #059669);
            }
        """);
    }
}