No description
Find a file
2026-07-08 21:09:20 +00:00
src initial commit 2026-07-08 21:09:20 +00:00
.gitattributes initial commit 2026-07-08 21:09:20 +00:00
.gitignore initial commit 2026-07-08 21:09:20 +00:00
composer.json initial commit 2026-07-08 21:09:20 +00:00
LICENSE.md initial commit 2026-07-08 21:09:20 +00:00
README.md initial commit 2026-07-08 21:09:20 +00:00

Laravel Flash Notifications

Tiny fluent helper for stashing a single one-shot flash message in the Laravel session for the next request to render. No bundled views, no opinion on your CSS framework, just session keys you can render any way you like. Tested on Laravel 11 and 12.

Installation

composer require lithiumhosting/laravel-flash-notifications

The service provider and Flash facade alias auto-register.

Usage

// Helper
flash()->success('Saved');
flash()->error('Could not save');
flash()->warning('Heads up')->important();
flash()->info('FYI');
flash()->overlay('Modal-style message', 'Title');

// Or via the facade
Flash::success('Saved');

Every flash call writes the following session keys, scoped to the next request:

Session key Always set Purpose
flash_notification.title yes Heading text
flash_notification.message yes Body text
flash_notification.level yes success / danger / warning / info
flash_notification.overlay optional Render as a modal instead of an inline alert
flash_notification.important optional Don't auto-dismiss
flash_notification.page optional Page-level (not action-scoped) flash
flash_notification.autoclose optional Hint that the renderer can auto-dismiss

Rendering

You own the render. A minimal Blade partial:

@if (session()->has('flash_notification.message'))
    <div class="alert alert-{{ session('flash_notification.level', 'info') }}">
        <strong>{{ session('flash_notification.title') }}</strong>
        <p>{!! session('flash_notification.message') !!}</p>
    </div>
@endif

@include that partial wherever your layout's flash slot lives.

License

This package, laravel-flash-notifications is licensed under The MIT License (MIT). Please see License File for more information.

Is it any good?

Yes.

When people first hear about a new product, they frequently ask if it is any good. A Hacker News user remarked:

Note to self: Starting immediately, all raganwald projects will have a "Is it any good?" section in the readme, and the answer shall be "yes.".