How to detect disconnection at browser side

An application is implemented with @Push in Flow mode, if web browser loses connection to the server, how to detect the disconnection? and then prompt a message to user automatically.

That’s automatically done by Vaadin - if you change your connectivity you can see a “Offline” Banner at the top of your application

Could it be handled by application?

Flow is running on the server… so it’s already too late / re-connected and you probably got and out-of-sync error which forces a full client refresh… so I doubt that there is a sane hook for flow. You might be able to do it with @PWA or when using Hilla.

Putting what Christian said in other words, what is your actual need behind the question. Why you need to detect the disconnection? What you need to do while browser is disconnected? And other questions …