edulazaro/wiretoast
Framework-agnostic toast notifications for Laravel with optional Livewire helper and Alpine support. Pure CSS themes (no Tailwind/Bootstrap), zero JS deps, 5 types, 7 positions, dark mode, progress bar, titles/messages, group mode, and easy custom theming via CSS variables.
WireToast is a lightweight, framework-agnostic solution designed to integrate seamlessly into Laravel/Livewire ecosystems. Its zero-JS-dependency approach aligns with Laravel’s backend-first philosophy while providing a drop-in API for Livewire and Alpine.js. The package’s pure CSS themes avoid build tool conflicts (e.g., Vite/Tailwind) and enable design system consistency without requiring frontend expertise. Its modular architecture (component + API) allows for selective adoption—e.g., using only the Livewire helper or the full Alpine.js/JS API—reducing coupling with other systems.
Key Fit Criteria:
$this->notify() helper, reducing boilerplate for backend-triggered toasts.Integration is low-risk due to:
composer require command with minimal dependencies (PHP 8.2+).@wiretoast/js/wiretoast.js and @wiretoast/css/wiretoast.css (recommended for modern stacks).vendor:publish for standalone assets (suitable for legacy projects).<x-wiretoast /> requires no template overrides for basic usage, with optional props for theming/positioning.notify() method across Livewire, Alpine.js, and JS, reducing context-switching for developers.Feasibility Risks:
wire:ignore or wire:key if needed).| Risk Area | Severity | Mitigation |
|---|---|---|
| Livewire Hydration Mismatches | Medium | Test with wire:key or wire:ignore on the toast container. |
| CSS Specificity Conflicts | Low | Use scoped CSS (e.g., [data-wiretoast]) or shadow DOM for custom themes. |
| Dark Mode Inconsistencies | Low | Verify prefers-color-scheme detection works alongside Tailwind/other dark mode solutions. |
| Performance Overhead | Low | Toasts are lightweight; bundle with Vite for optimal caching. |
| Legacy Laravel/Livewire | High | Requires Laravel 11+ and Livewire 3.0+; assess upgrade path if using older versions. |
| Localization Gaps | Medium | Pair with laravel-localization for RTL/multi-language support. |
vendor:publish approach work for the team’s deployment pipeline?prefers-color-scheme detection interact with them?laravel-localization) be needed?WireToast is optimized for:
$this->notify() helper for seamless backend-to-frontend communication.$dispatch('notify', ...).window.notify() for non-Alpine contexts.vendor:publish.Stack Mismatches to Address:
wire:key or wire:ignore.| Phase | Steps | Dependencies |
|---|---|---|
| Assessment | Audit existing toast implementations (custom JS, libraries, or none). Identify gaps in consistency, theming, and dark mode. | Design system, current build tools |
| Pilot Integration | Install WireToast in a non-production environment. Test: | Dev/staging environment |
1. Vite setup: Import @wiretoast/js/wiretoast.js and @wiretoast/css/wiretoast.css. |
Vite/Webpack | |
2. Blade setup: Add <x-wiretoast /> to the main layout. |
Laravel Blade | |
3. Livewire test: Replace $this->dispatch('alert', ...) with $this->notify(). |
Livewire 3.0+ | |
4. Alpine.js test: Replace custom toast logic with $dispatch('notify', ...). |
Alpine.js | |
5. JS test: Replace window.toast() with window.notify(). |
Vanilla JS | |
| Theming Validation | Select a base theme (e.g., "soft" or "chatgpt") and validate against design system guidelines. Test custom themes via CSS variables if needed. | Design system team |
| Dark Mode Testing | Verify prefers-color-scheme detection works alongside existing dark mode solutions. Test forced light/dark modes via props. |
QA team |
| Performance Benchmark | Measure asset size impact (bundled vs. standalone). Test toast rendering/removal performance in high-frequency scenarios (e.g., bulk API errors). | Frontend perf tools |
| Rollout | Gradually replace toast implementations in key flows (e.g., auth, forms, API responses). Monitor for hydration issues or CSS conflicts. | Feature teams |
| Full Adoption | Deprecate custom toast logic. Update documentation and onboarding guides. | DevOps, documentation team |
| Compatibility Check | Status | Notes |
|---|---|---|
| Laravel 11+ | ✅ Native Support | Uses Laravel’s Blade components and service container. |
| Livewire 3.0+ | ✅ Native Support | $this->notify() helper integrates with Livewire’s event system. |
| Alpine.js | ✅ Native Support | $dispatch('notify', ...) works out-of-the-box. |
| Vanilla JS | ✅ Native Support | window.notify() global function. |
| Vite/Webpack | ✅ Native Support | Zero-config imports via @wiretoast/.... |
| No Bundler (standalone assets) | ✅ Supported | vendor:publish publishes CSS/JS to public/vendor/wiretoast/. |
| Tailwind CSS | ⚠️ Partial Support | Custom themes may conflict; use scoped CSS or shadow DOM. |
How can I help you explore Laravel packages today?