Posts

Showing posts with the label Browser API

Picture-in-Picture in Blazor: Using Browser APIs Without Fighting Blazor Server

Image
When we need a new UI feature in Blazor, our default reflex is often to hunt down a NuGet package, a third-party component library, or write an elaborate C# wrapper. But modern browsers already handle many of these capabilities natively—often much better than a custom abstraction would. Picture-in-Picture (PiP) is a classic example. Whether you are floating a video feed or creating an always-on-top dashboard monitor, the browser provides direct APIs to manage these detached windows. However, wiring PiP into a Blazor Server application reveals a subtle architectural trap: browser user-activation requirements . Here is how the Picture-in-Picture APIs work, why standard Blazor @onclick handlers break them, and how to structure JavaScript interop so the browser and server cooperate cleanly. The Blazor Server SignalR Trap Most browser features that affect windowing or OS integration require transient user activation . The browser will only execute methods like video.requestPictureInPictur...

Keeping Multiple Blazor Tabs in Sync with the Browser Broadcast Channel API

Image
  A user opens your Blazor application in one browser tab. Then they open a second tab, perhaps to compare information or keep two parts of the application visible at the same time. They change something in the first tab. Nothing happens in the second tab. This is expected. Each browser tab has its own page, JavaScript context, and Blazor Server circuit. Even though both tabs are displaying the same application for the same user, they don’t automatically share live state. You could solve this with SignalR, a server-side notification service, or a distributed messaging system. For many applications, however, that would be far more infrastructure than the problem requires. When the communication only needs to happen between tabs from the same application in the same browser, the browser already provides a lightweight solution: the Broadcast Channel API . In this article, we will examine: What developers sometimes mean by the “Broadcast API” What the Broadcast Channel API actually is ...