PHPackages                             atomcoder/laravel-toasty - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. atomcoder/laravel-toasty

ActiveLibrary[Templating &amp; Views](/categories/templating)

atomcoder/laravel-toasty
========================

Pines-inspired toast notifications for Laravel Blade and Livewire.

1.0.0(1mo ago)21621MITPHPPHP ^8.1

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/RichieMcMullen/laravel-toasty)[ Packagist](https://packagist.org/packages/atomcoder/laravel-toasty)[ RSS](/packages/atomcoder-laravel-toasty/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Laravel Toasty
==============

[](#laravel-toasty)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6bff2665da7a0dfb90217353785daed30b0cedde54fb1a6037584f5b6c5e9c32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61746f6d636f6465722f6c61726176656c2d746f617374793f7374796c653d666c61742d737175617265)](https://packagist.org/packages/atomcoder/laravel-toasty)[![Total Downloads](https://camo.githubusercontent.com/ab1ad22707b328e78721f9c7f47fff6972e312d85d8a609138fff858f14e330b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61746f6d636f6465722f6c61726176656c2d746f617374793f7374796c653d666c61742d737175617265)](https://packagist.org/packages/atomcoder/laravel-toasty)[![PHP Version](https://camo.githubusercontent.com/61faa4dc049af345c0a55a345f3d3b939539411a741034aa7b186cffb866f910/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f61746f6d636f6465722f6c61726176656c2d746f617374793f7374796c653d666c61742d737175617265)](https://packagist.org/packages/atomcoder/laravel-toasty)[![Laravel](https://camo.githubusercontent.com/b31e8f02fba610495e42c0631a0cec07f1ebf37814b42a81b1fc790ca7ac92fb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3130253230746f25323031332d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://laravel.com)[![License](https://camo.githubusercontent.com/a16b95c95860297084caae5de15c0b61d9eaf9a1af3fab2ffdbdaf113dcdaf4e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f5269636869654d634d756c6c656e2f6c61726176656c2d746f617374793f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Release](https://camo.githubusercontent.com/267e4a27da2692afb2d276130877c354a8d487a4f1e18f8b4f4644b999b8ff6a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f5269636869654d634d756c6c656e2f6c61726176656c2d746f617374793f7374796c653d666c61742d737175617265)](https://github.com/RichieMcMullen/laravel-toasty/releases)[![Stars](https://camo.githubusercontent.com/e40ee79dd3d992b5841195cd50cd2450cd967d703c4fa4813e91f8aaee8d1dc5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f5269636869654d634d756c6c656e2f6c61726176656c2d746f617374793f7374796c653d666c61742d737175617265)](https://github.com/RichieMcMullen/laravel-toasty/stargazers)

[![Laravel Toasty](docs/images/header.png)](docs/images/header.png)

Toast notifications for Laravel Blade, Livewire, Alpine, and JavaScript.

Laravel Toasty works with:

- standard Laravel controllers and redirects
- Blade layouts
- Alpine
- Livewire
- plain browser JavaScript

The package uses namespaced APIs so it does not clash with Flux toasts or generic `toast()` helpers.

See [CHANGELOG.md](CHANGELOG.md) for release history.

What You Get
------------

[](#what-you-get)

- `` Blade component
- `@laravelToasty` Blade directive
- `laravel_toasty()` helper
- `LaravelToasty` facade alias
- Livewire support through the `InteractsWithToasts` trait
- `window.LaravelToasty` JavaScript API
- bundled CSS inside the package, so Tailwind setup is not required

Requirements
------------

[](#requirements)

- PHP `8.1+`
- Laravel `10+`
- Alpine.js `3+`

Livewire is optional.

Installation
------------

[](#installation)

Install with Composer:

```
composer require atomcoder/laravel-toasty
```

Publish the config if you want to change defaults:

```
php artisan vendor:publish --tag=laravel-toasty-config
```

Publish the views only if you want to override the package markup:

```
php artisan vendor:publish --tag=laravel-toasty-views
```

You do not need to:

- install Tailwind for this package
- add vendor Blade paths to Tailwind `content`
- import a separate package stylesheet

Quick Start
-----------

[](#quick-start)

### 1. Render the toast stack once

[](#1-render-the-toast-stack-once)

Add this near the end of your main layout, usually before ``:

```

```

Or:

```
@laravelToasty
```

### 2. Make sure Alpine is loaded

[](#2-make-sure-alpine-is-loaded)

If your app already has Alpine, you are done.

If not:

```

```

### 3. Trigger a toast

[](#3-trigger-a-toast)

Normal Laravel request:

```
laravel_toasty()->success('Profile updated');
```

Livewire immediate toast:

```
$this->dispatchLaravelToastySuccess('Profile updated');
```

Browser JavaScript:

```

    window.LaravelToasty.notify('Profile updated');

```

How It Works
------------

[](#how-it-works)

Laravel Toasty supports two main server-side flows:

### Session toast

[](#session-toast)

Use this in controllers, middleware, or normal Laravel request code:

```
laravel_toasty()->success('Saved');
```

That stores the toast in the session, and the next page render shows it.

### Immediate Livewire toast

[](#immediate-livewire-toast)

Use this inside a Livewire component action:

```
$this->dispatchLaravelToastySuccess('Saved');
```

That dispatches a browser event immediately through the current component, so the user sees the toast without leaving the page.

Main APIs
---------

[](#main-apis)

### Helper

[](#helper)

```
laravel_toasty()
```

### Facade

[](#facade)

```
LaravelToasty::success('Saved');
```

### Blade

[](#blade)

```

@laravelToasty
```

### JavaScript

[](#javascript)

```
window.LaravelToasty.notify('Saved');
window.LaravelToasty.layout('expanded');
```

Full Usage Examples
-------------------

[](#full-usage-examples)

### Example 1: Standard controller redirect

[](#example-1-standard-controller-redirect)

Use this when the request ends with a redirect.

```
