DEV Community

Cover image for Communicating between browser tabs

Communicating between browser tabs

Baedyl on May 27, 2021

I recently came across the issue of sharing some data between different tabs of the same web application. Using OAuth to retrieve an external provi...
Collapse
 
alvaromontoro profile image
Alvaro Montoro

Interesting. In the past I used localStorage with the storage event. But this seems to work in a different way, I need to look into this because it looks simpler and more complete. Thanks for sharing!

Collapse
 
link2twenty profile image
Andrew Bone

Main problem is it's not really fully supported yet. If we ignore IE (and we should) safari still doesn't have support, which means iOS doesn't either.

If you want to track it here's the issue on webkit.

Collapse
 
baedyl profile image
Baedyl

I actually tried using local storage for this matter and could not achieve the same result. Just do it!

Collapse
 
leob profile image
leob

That's incredibly interesting, hadn't heard about it, there are so many new and useful APIs in the evolving browser standards, it's hard to keep track of them ... which browsers (versions) support this new API ?

Collapse
 
baedyl profile image
Baedyl

Starting at Chrome 54 and Firefox 38, the complete list can be found here: developer.mozilla.org/en-US/docs/W...

Collapse
 
leob profile image
leob

You mean here: developer.mozilla.org/en-US/docs/W... ... good to know, very useful!

Collapse
 
ben profile image
Ben Halpern

Interesting!

Collapse
 
thormeier profile image
Pascal Thormeier

TIL, that will come in handy, thank you! Browser support seems to be good, although no Safari (neither desktop nor iOS) supports it, but there seems to be a polyfill.

Collapse
 
patzistar profile image
Patrick Schadler

Didn't knew that this is possible, thanks! Would probably went the localStorage route or even websockets and a backend logic, which handles all the logic and sends updates to all listener.

Collapse
 
jsnanigans profile image
Brendan Mullins

This looks great but for now localstorage will have to suffice even though its harder.. at least it is supported by all browsers.

Collapse
 
egotr profile image
nghialv

I think "communicating" between tabs is cooler than "share data" man.
Thanks for your share !

Collapse
 
baedyl profile image
Baedyl

Definetly! Thanks for your feedback!

Collapse
 
mrdulin profile image
official_dulin

Good to know this API.