Firebase/auth docs explain well how to login via magic email link. Issue that I have is that magic email link is opened in a new tab/window which means that after a successful authentication I have two tabs open. What is the best practice to close new/old window/tab if there is already one open?
One way is to use localStorage API to check for this condition. See this question on how to use it: JavaScript: sharing data between tabs
From UX standpoint: while closing a duplicate tab seems like a good idea on a first glance, as a user I'd not be too happy about losing a tab with it's back history. I've seen at least one website that applied a whole-page overlay saying "this is open already in another tab" to disable interaction.