Laravel SSE
Sarfraz Ahmed

Sarfraz Ahmed @sarfraznawaz2005

About: Hello, I am Sarfraz Ahmed, a self-taught programmer from Karachi, Pakistan mainly involved in PHP, MySQL, HTML/CSS, JavaScript/jQuery for around 10 years now.

Location:
Karachi, Pakistan
Joined:
Dec 13, 2017

Laravel SSE

Publish Date: Aug 10 '19
7 4

Laravel package to provide Server Sent Events functionality for your app. You can use this package to show instant notifications to your users without them having to refresh their pages.


Checkout Laravel SSE

Comments 4 total

  • KP
    KPAug 11, 2019

    Will this work with a Nuxt.js Frontend talking to Laravel APIs?

    • Sarfraz Ahmed
      Sarfraz AhmedAug 11, 2019

      Though I haven't worked with Nuxt.js but general idea is that package returns "message" event which you can hook into. For example, here is vanilla JS that can be used:

      <script>
      var es = new EventSource("{{route('__sse_stream__')}}");
      
      es.addEventListener("message", function (e) {
          var data = JSON.parse(e.data);
          alert(data.message);
      }, false);
      
      </script>
      


      `

      I assume you can do something similar with Nuxt.JS too to capture "message" event and react to it.

      • KP
        KPAug 14, 2019

        Thank you! I'll give this a go when I find the time.

  • Odunlade Samuel
    Odunlade SamuelJul 28, 2020

    Can i use this with react?

Add comment