Oddbean new post about | logout
 Actually there is a "browser relay", Snort has it, Spring browser too. Not sure about Snort, with Spring it's a fake Websocket interface installed to global that will redirect all requests to a custom "local-relay" url to a relay running in a service worker. There's a dumb relay in sw now, which I didn't bother to make efficient yet, but it can be improved. The main limitation is browser js performance and storage size limits, I guess.

But this is only for your own app. If you wanted to share this relay, that's possible too using postMessage for cross-origin communication (with the same fake websocket installed in the app to trick the libs it's using (ndk/nostr-tools) to use the local relay). Haven't tried it though, there a limitation will probably be that the relay tab must be kept open. 
 Actually, an app could open an invisible iframe and talk to it using postMessage, then no need for an open tab, the relay would live in the iframe's service worker. Could be pretty cool! 
 Woah! This is exactly what I was thinking, a relay in a browser tab. Can you point to some code I can check out? 
 Websocket proxy to local relay https://github.com/nostrband/nostr-universe/blob/main/app/src/modules/relay-proxy.ts 
 Websocket proxy talks to the relay running in a worker using comlink lib which is part of the framework we used, but that's just a wrapper for postMessage