core icon indicating copy to clipboard operation
core copied to clipboard

How to broadcast new orders to admin panel in real-time using nuxt-hub realtime or websockets?

Open mrkaashee opened this issue 8 months ago • 3 comments

Hi Nuxt Hub team,

I'm working on implementing real-time order updates using nuxt-hub in my Nuxt-based e-commerce website. I've successfully established a WebSocket connection within my routes, following the documentation.

Now, I’d like to notify the admin panel in real time when a new order is placed. Is there a recommended way to use something like:

await useHubWs().broadcast('orders', savedOrder);

...to broadcast the new order to connected clients (e.g., the admin panel)?

What would be the best practice to achieve this functionality using Nuxt Hub?

Thanks in advance!

mrkaashee avatar May 06 '25 13:05 mrkaashee

crossws v0.4.0 has introduced global publish to the Cloudflare adapter, and namespaces in pub/sub so this should be possible soon :) https://github.com/h3js/crossws/releases/tag/v0.4.0

RihanArfan avatar May 26 '25 01:05 RihanArfan

I also have a similar requirement; my real-time interface should receive WebSocket notifications when a user visits

https://sink.cool/dashboard/realtime

miantiao-me avatar Jun 02 '25 02:06 miantiao-me

is there any workaround until that's possible?

thunfisch987 avatar Jun 03 '25 12:06 thunfisch987