---
title: "Discussion on \"Getting Zalo Web to Run in Every Tab with One Socket\" | Hashnode"
description: "Discussion on \"Getting Zalo Web to Run in Every Tab with One Socket\". How Zalo Web keeps you to one tab, and how a small extension lets every tab share one connection"
url: "https://hashnode.com/posts/getting-zalo-web-to-run-in-every-tab-with-one-socket/6aef5aea4085efce9fc2d4ec"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Getting Zalo Web to Run in Every Tab with One Socket](https://blog.nh4ttruong.me/getting-zalo-web-to-run-in-every-tab-with-one-socket?utm_source=hashnode&utm_medium=feed)

How Zalo Web keeps you to one tab, and how a small extension lets every tab share one connection

Nov 7 · 8 min read · blog.nh4ttruong.me  
Read the article

-   [#browser-extension](https://hashnode.com/tag/browser-extension)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#websockets](https://hashnode.com/tag/websockets)
-   [#zalo](https://hashnode.com/tag/zalo)

## Written by

[Nhật Trường](https://hashnode.com/@nh4ttruong)

@nh4ttruong · Ho Chi Minh City

  
[View profile](https://hashnode.com/@nh4ttruong)

DevSecOps Engineer

An engineer who just writes YAML, coding stuff, chats with AI, and spends my days making things secure, automating what I can, and debugging what I must.

## Responses 2

Markdown supported · ⌘↵ to post

[netproxy](https://hashnode.com/@argumentmoney8117)

[Nov 7](https://hashnode.com/posts/getting-zalo-web-to-run-in-every-tab-with-one-socket/6aef5aea4085efce9fc2d4ec/comment/6aefb499067a514fd7918e4b)

The two-locks framing makes the whole thing easy to follow, and using the Web Locks API for leader election is a neat fit for this problem. The hub/follower split with a virtual WebSocket relay is an elegant way to keep every tab believing it has its own connection. The honest 'what it does not fix' section is appreciated too.

[Nhật Trường](https://hashnode.com/@nh4ttruong)

[Nov 9](https://hashnode.com/posts/getting-zalo-web-to-run-in-every-tab-with-one-socket/6aef5aea4085efce9fc2d4ec/comment/6aefb499067a514fd7918e4b#reply-6af195b47f00aa502ff185aa)

Thanks for reading! The browser does the leader election, so when the hub tab closes, another tab takes over with no extra code.
