- How do I install tuhin-su/livewire-swal in a Laravel Livewire app?
- Run composer require tuhin-su/livewire-swal. The package is zero-config by default: it auto-injects the SweetAlert2 CDN and JavaScript event wrapper into pages, so no NPM or Vite build is required. You can optionally publish the config file if you want to self-host SweetAlert2 or use a custom CDN URL.
- Which Laravel and Livewire versions does livewire-swal support?
- The README lists Laravel 10 or 11+ and Livewire 3+ as requirements. Verify the composer.json constraints against your project before installing, especially if you are still on Livewire 2. Because adoption is low, test compatibility in a staging branch before rolling it out broadly.
- Do I need NPM or Vite to use SweetAlert2 with this Laravel package?
- No. The default zero-configuration mode injects the SweetAlert2 CDN and the event wrapper automatically, so it works without NPM, Vite, or layout edits. If you prefer local assets, publish the config and point it at a self-hosted SweetAlert2 build.
- How do I add a SweetAlert2 confirm dialog before deleting a Livewire record?
- Use the swalConfirm helper from your Livewire component to show a confirm modal and handle the confirm or cancel events. Wrap the call in a project-owned helper so button labels, icons, and event names stay consistent. Test that cancel is safe and that confirm reliably triggers the intended Livewire delete action without race conditions.
- What is swalSecureAction in tuhin-su/livewire-swal?
- swalSecureAction is a helper for sensitive operations that forces multi-step confirmation and optional password prompts on the client. The server executes the target method only after validating a cryptographically signed payload, which helps prevent client-side bypasses. It is useful for destructive admin actions, but you should still review the package code and test the flow thoroughly.
- How do I verify the current user's password with SweetAlert2 in Livewire?
- Call swalVerifyCurrentUserPassword to prompt for the password and verify it server-side using Hash::check. The helper dispatches success or failure events so your Livewire component can continue or abort the action. Confirm the event names in your component and add tests for incorrect passwords and repeated clicks.
- Can I capture user input or prompt for a password using SweetAlert2 in Livewire?
- Yes. The package provides swalTakeInput for generic input prompts and swalPromptPassword for password prompts, both returning the captured value to PHP through Livewire events. Validate and sanitize the returned input server-side before using it. For high-risk actions, prefer swalVerifyCurrentUserPassword or swalSecureAction.
- Is tuhin-su/livewire-swal actively maintained and safe for production?
- The package currently has very low visible adoption, so treat it as a tactical convenience rather than strategic infrastructure. Pin the package and SweetAlert2 versions, review the source, and monitor upstream releases and Livewire compatibility. Add fallback behavior in case the SweetAlert2 CDN or assets fail to load.
- How do I self-host or customize the SweetAlert2 CDN in livewire-swal?
- Publish the package config file, then change the SweetAlert2 asset URL to your local build or preferred CDN. This is useful when you need version pinning, stricter CSP rules, or offline-friendly admin panels. After changing the URL, verify that modals, toasts, and confirm callbacks still work in the browser console.
- When should I avoid tuhin-su/livewire-swal and what are the alternatives?
- Avoid it for Inertia.js, Vue or React-heavy frontends, highly branded modals, or strict frontend performance budgets. It also may not suit teams needing TypeScript support or accessibility-certified dialogs. Alternatives include using SweetAlert2 directly, building your own Livewire modal components, or choosing a more mature alert package with active maintenance.