<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Syed Azlan Ali on Medium]]></title>
        <description><![CDATA[Stories by Syed Azlan Ali on Medium]]></description>
        <link>https://medium.com/@azlanali076?source=rss-f325afc1d791------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5fEzY1fmkeZDmvGIED5ebg.jpeg</url>
            <title>Stories by Syed Azlan Ali on Medium</title>
            <link>https://medium.com/@azlanali076?source=rss-f325afc1d791------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:55:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@azlanali076/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Real-Time Magic in React Native: Connecting to Laravel Reverb with react-native-reverb]]></title>
            <link>https://medium.com/@azlanali076/real-time-magic-in-react-native-connecting-to-laravel-reverb-with-react-native-reverb-3dca123774d0?source=rss-f325afc1d791------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dca123774d0</guid>
            <category><![CDATA[real-time-communication]]></category>
            <category><![CDATA[pusher]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Syed Azlan Ali]]></dc:creator>
            <pubDate>Thu, 04 Jun 2026 07:35:27 GMT</pubDate>
            <atom:updated>2026-06-04T07:35:27.017Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJg9QHFb6tzVO2S-66JjLA.png" /></figure><p>If you’ve ever built a Laravel backend and wanted to push real-time events to a React Native app — order updates, live notifications, chat messages — you’ve probably hit a wall. Laravel Echo works beautifully on the web, but mobile is a different story. That’s exactly the gap that react-native-reverb fills.</p><p>In this article, we’ll explore what the package does, why it matters, how to set it up, and walk through a practical real-world example: live order status tracking.</p><h3>The Problem: Real-Time in React Native Was a Pain</h3><p>Laravel Reverb is Laravel’s own first-party WebSocket server, released in 2024. It speaks the Pusher protocol, integrates seamlessly with Laravel’s broadcasting system, and is stupidly easy to self-host. On the web side, Laravel Echo + the Pusher JS client handles everything elegantly.</p><p>But on React Native? You had two not-so-great options:</p><ol><li><strong>Pusher’s official React Native SDK</strong> — works, but it’s tied to Pusher’s hosted infrastructure. Running your own Reverb server means you’re on your own.</li><li><strong>Roll your own WebSocket client</strong> — doable, but you have to re-implement channel subscriptions, authentication, event parsing, and the Pusher wire protocol yourself.</li></ol><p>Neither option felt right if you’re already invested in the Laravel ecosystem.</p><h3>Enter react-native-reverb</h3><p><a href="https://github.com/azlanali076/react-native-reverb">react-native-reverb</a> is a React Native <strong>TurboModule</strong> wrapper built specifically for Laravel Reverb. It speaks natively to both iOS and Android, handles private channel authentication, and exposes a clean, promise-based API that feels right at home alongside your existing Laravel code.</p><p>Key things it does out of the box:</p><ul><li>Connects to your self-hosted Reverb server</li><li>Subscribes to <strong>public</strong> and <strong>private</strong> channels</li><li>Listens for <strong>broadcasted events</strong> (e.g., OrderUpdated)</li><li>Listens for <strong>Laravel notifications</strong> sent via notifyNow() or the Notifiable trait</li><li>Cleans up listeners and channels when you’re done</li></ul><p>Because it’s built as a TurboModule (React Native’s modern native module architecture), it avoids the overhead of the old bridge and performs much better at scale.</p><h3>Installation</h3><pre>npm install react-native-reverb<br># or<br>yarn add react-native-reverb</pre><p>Since it supports <strong>autolinking</strong> (React Native 0.71+), you don’t need any manual linking. For iOS, just run:</p><pre>cd ios &amp;&amp; pod install</pre><p>Android needs nothing extra — autolinking registers the TurboModule automatically.</p><h3>Basic Setup</h3><p>Here’s how you initialize the client and connect to your Reverb server:</p><pre>import { ReverbClient } from &#39;react-native-reverb&#39;;<br><br>const client = new ReverbClient({<br>  appKey: &#39;your-reverb-app-key&#39;,<br>  scheme: &#39;https&#39;,<br>  url: &#39;your-reverb-host.com&#39;,<br>  auth: {<br>    endpoint: &#39;https://your-app.com/broadcasting/auth&#39;,<br>    headers: {<br>      Authorization: `Bearer ${userToken}`,<br>    },<br>  },<br>});<br><br>await client.connect();</pre><p>The auth block is used for private channel authentication — it hits your Laravel app&#39;s /broadcasting/auth endpoint with the user&#39;s bearer token, exactly like Echo would on the web.</p><h3>Real-World Example: Live Order Status Tracking</h3><p>Let’s say you have an e-commerce app. When a user places an order, they should see status updates in real-time — Processing, Shipped, Delivered — without pulling. Here&#39;s how to wire this up end to end.</p><h3>Laravel Side</h3><p>First, create a broadcastable event:</p><pre>// app/Events/OrderUpdated.php<br><br>class OrderUpdated implements ShouldBroadcast<br>{<br>    use Dispatchable, InteractsWithSockets, SerializesModels;<br><br>    public function __construct(public Order $order) {}<br><br>    public function broadcastOn(): array<br>    {<br>        return [<br>            new PrivateChannel(&quot;App.Models.Order.{$this-&gt;order-&gt;id}&quot;),<br>        ];<br>    }<br>    <br>    public function broadcastWith(): array<br>    {<br>        return [<br>            &#39;status&#39; =&gt; $this-&gt;order-&gt;status,<br>            &#39;updated_at&#39; =&gt; $this-&gt;order-&gt;updated_at-&gt;toISOString(),<br>        ];<br>    }<br>}</pre><p>Then authorize the private channel in routes/channels.php:</p><pre>Broadcast::channel(&#39;App.Models.Order.{orderId}&#39;, function ($user, $orderId) {<br>    return Order::where(&#39;id&#39;, $orderId)<br>                -&gt;where(&#39;user_id&#39;, $user-&gt;id)<br>                -&gt;exists();<br>});</pre><p>When an order’s status changes, fire the event:</p><pre>event(new OrderUpdated($order));</pre><h3>React Native Side</h3><p>Now in your order screen, subscribe to that private channel:</p><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>import { View, Text } from &#39;react-native&#39;;<br>import { ReverbClient } from &#39;react-native-reverb&#39;;<br><br>const client = new ReverbClient({<br>  appKey: process.env.REVERB_APP_KEY!,<br>  scheme: &#39;https&#39;,<br>  url: process.env.REVERB_HOST!,<br>  auth: {<br>    endpoint: `${process.env.API_URL}/broadcasting/auth`,<br>    headers: {<br>      Authorization: `Bearer ${authToken}`,<br>    },<br>  },<br>});<br>export default function OrderScreen({ orderId }: { orderId: string }) {<br>  const [status, setStatus] = useState(&#39;Pending&#39;);<br>  useEffect(() =&gt; {<br>    let channel: any;<br>    const setupReverb = async () =&gt; {<br>      await client.connect();<br>      channel = await client.private(`App.Models.Order.${orderId}`);<br>      channel.listen(&#39;App\\Events\\OrderUpdated&#39;, (data: { status: string }) =&gt; {<br>        setStatus(data.status);<br>      });<br>    };<br>    setupReverb();<br>    <br>    return () =&gt; {<br>      channel?.removeAllListeners();<br>      client.disconnect();<br>    };<br>  }, [orderId]);<br>  return (<br>    &lt;View&gt;<br>      &lt;Text&gt;Order Status: {status}&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><p>That’s it. When your backend fires OrderUpdated, the user&#39;s phone updates instantly — no polling, no extra infrastructure.</p><h3>Listening for Laravel Notifications</h3><p>Beyond events, react-native-reverb also supports Laravel&#39;s notification broadcasting. If you&#39;re using notifyNow() or queued notifications with the broadcast channel, you can listen for them like this:</p><pre>const channel = await client.private(`App.Models.User.${userId}`);<br><br>channel.notifications((notification: any) =&gt; {<br>  console.log(&#39;New notification:&#39;, notification.type, notification.data);<br>});</pre><p>On the Laravel side, your notification just needs to implement ShouldBroadcast and use BroadcastChannel:</p><pre>class NewMessageNotification extends Notification implements ShouldBroadcast<br>{<br>    public function via($notifiable): array<br>    {<br>        return [&#39;broadcast&#39;];<br>    }<br>    public function toBroadcast($notifiable): BroadcastMessage<br>    {<br>        return new BroadcastMessage([<br>            &#39;message&#39; =&gt; $this-&gt;message-&gt;body,<br>            &#39;sender&#39; =&gt; $this-&gt;message-&gt;sender-&gt;name,<br>        ]);<br>    }<br>}</pre><h3>API Reference at a Glance</h3><pre>ReverbClient<br>  new ReverbClient(options)      Create a client instance<br>  client.connect()               Connect to the Reverb WebSocket server<br>  client.disconnect()            Disconnect and clean up<br>  client.channel(name)           Subscribe to a public channel<br>  client.private(name)           Subscribe to a private channel<br> <br>ReverbChannel / ReverbPrivateChannel<br>  channel.listen(event, cb)      Listen for a specific broadcasted event<br>  channel.notifications(cb)      Listen for Laravel notifications<br>  channel.removeListener(event)  Stop listening to one event<br>  channel.removeAllListeners()   Stop all listeners and unsubscribe<br>  channel.unsubscribe()          Unsubscribe from the channel<br>  channel.getChannelName()       Get the channel name string</pre><h3>A Few Things to Keep in Mind</h3><p><strong>TurboModule requirement.</strong> The package uses React Native’s New Architecture (TurboModules). Make sure your project has the new architecture enabled, which is the default from React Native 0.73+.</p><p><strong>Private channels need an auth endpoint.</strong> Your Laravel app must have BROADCAST_CONNECTION=reverb set and the broadcasting routes enabled (Broadcast::routes([&#39;middleware&#39; =&gt; [&#39;auth:sanctum&#39;]])).</p><p><strong>Connection lifecycle.</strong> Connect when the screen mounts, disconnect when it unmounts. The useEffect cleanup pattern shown above is the right approach.</p><p><strong>Environment variables.</strong> Don’t hardcode your Reverb app key or host — keep them in your .env file and expose them through your build config.</p><h3>Why This Matters</h3><p>The Laravel + React Native stack is genuinely underserved when it comes to real-time tooling. Most solutions either require you to pay for a third-party service, implement the Pusher protocol from scratch, or live without proper private channel support.</p><p>react-native-reverb closes that gap neatly. It&#39;s built on modern React Native internals, it mirrors the mental model of Laravel Echo on the web, and it handles the hairy parts — authentication, channel types, notification broadcasting — so you don&#39;t have to.</p><p>If you’re building a Laravel-powered mobile app and need real-time features, this package deserves a serious look.</p><p><em>Find the package on GitHub at </em><a href="https://github.com/azlanali076/react-native-reverb"><em>azlanali076/react-native-reverb</em></a><em> and install it via npm.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dca123774d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>