Queue a broadcast instead of blocking the save

ShouldBroadcast queues the event. ShouldBroadcastNow runs it inside the request. The Vue listener is the Reverb guide.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-should-broadcast-vue.md
ShouldBroadcast queues the event. ShouldBroadcastNow runs it inside the request. The Vue listener is the Reverb guide.
Do not listen with useEcho on a public channel.
Do not put the provider key, or the Reverb secret, in the event payload.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “ShouldBroadcast Vue” implement ShouldBroadcastNow and then every save waits on the socket. ShouldBroadcast implements the queue. The event class, the public channel, and useEchoPublic are already in the Reverb guide. This page is the interface and the worker.

TL;DR

  • ShouldBroadcast queues the event.
  • ShouldBroadcastNow runs it inside the request.
  • The Vue listener is the Reverb guide.
  • Do not listen with useEcho on a public channel.

Who it's for: Laravel + Vue developers

Applies to: Laravel 13 · Vue 3

The fix#

php
class PostPublished implements ShouldBroadcast
{
    // broadcastOn stays the public Channel from the Reverb guide
}

PostPublished::dispatch($post) after the row exists. Nothing reaches the browser until a worker is running. Local:

shell
php artisan queue:listen

If the title never appears, check the worker before you rewrite the Vue listener. ShouldBroadcastNow is the tool when the event must go out before the response, and you accept the cost. A post save is not that case.

What to avoid#

Gotcha

Do not listen with useEcho on a public channel. The Reverb guide shows why that hook asks for a private channel and then misses this event. Do not put the provider key, or the Reverb secret, in the event payload.

FAQ#

How do I queue a broadcast instead of blocking the save?

ShouldBroadcast queues the event. ShouldBroadcastNow runs it inside the request. The Vue listener is the Reverb guide.

What goes wrong with ShouldBroadcast Vue?

Many developers implement ShouldBroadcastNow and then every save waits on the socket. Do not listen with useEcho on a public channel.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.