I ended up adopting code from the High Performance Browser Networking book and some code examples by Google that were written like 8 years ago. It was painful to replace the outdated APIs with new ones and rewrite in TypeScript, but I eventually did it.
https://github.com/adhamsalama/webrtc/
Then I used it with WebAssembly to run a distributed SQLite database in the browser for peer-to-peer collaboration.
https://github.com/adhamsalama/sqlite-wasm-webrtc
Probably the coolest projects I have ever done, and they contain almost no backend code at all (I am a backend dev).