{"id":15464106,"url":"https://github.com/maschad/test-js-libp2p-example","last_synced_at":"2025-11-17T13:21:11.739Z","repository":{"id":230385612,"uuid":"701456306","full_name":"maschad/test-js-libp2p-example","owner":"maschad","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-06T17:10:23.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-08T06:57:12.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maschad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-06T17:10:15.000Z","updated_at":"2023-10-06T17:10:27.000Z","dependencies_parsed_at":"2024-04-01T08:31:39.589Z","dependency_job_id":null,"html_url":"https://github.com/maschad/test-js-libp2p-example","commit_stats":null,"previous_names":["maschad/test-js-libp2p-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maschad%2Ftest-js-libp2p-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maschad%2Ftest-js-libp2p-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maschad%2Ftest-js-libp2p-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maschad%2Ftest-js-libp2p-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maschad","download_url":"https://codeload.github.com/maschad/test-js-libp2p-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246642477,"owners_count":20810596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T00:24:46.642Z","updated_at":"2025-11-17T13:21:06.707Z","avatar_url":"https://github.com/maschad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-libp2p-webrtc Browser to Browser\n\nThis example leverages the [vite bundler](https://vitejs.dev/) to compile and serve the libp2p code in the browser. You can use other bundlers such as Webpack, but we will not be covering them here.\n\n## Build the `@libp2p/webrtc` package\n\nBuild the `@libp2p/webrtc` package by calling `npm i \u0026\u0026 npm run build` in the repository root.\n\n## Running the Relay Server\n\nFor browsers to communicate, we first need to run the LibP2P relay server:\n\n```shell\nnpm run relay\n```\n\nCopy one of the multiaddresses in the output.\n\n## Running the Example\n\nIn a separate console tab, install dependencies and start the Vite server:\n\n```shell\nnpm i \u0026\u0026 npm run start\n```\n\nThe browser window will automatically open.  Let's call this `Browser A`.\nUsing the copied multiaddress from the Go or NodeJS relay server, paste it into the `Remote MultiAddress` input and click the `Connect` button.\n`Browser A` is now connected to the relay server.\nCopy the multiaddress located after the `Listening on` message.\n\nNow open a second browser with the url `http://localhost:5173/`.  Let's call this `Browser B`.\nUsing the copied multiaddress from `Listening on` section in `Browser A`, paste it into the `Remote MultiAddress` input and click the `Connect` button.\n`Browser B` is now connected to `Browser A`.\nCopy the multiaddress located after the `Listening on` message.\n\nUsing the copied multiaddress from `Listening on` section in `Browser B`, paste it into the `Remote MultiAddress` input in `Browser A` and click the `Connect` button.\n`Browser A` is now connected to `Browser B`.\n\nThe peers are now connected to each other.  Enter a message and click the `Send` button in either/both browsers and see the echo'd messages.\n\nThe output should look like:\n\n`Browser A`\n```text\nDialing '/ip4/127.0.0.1/tcp/57708/ws/p2p/12D3KooWRqAUEzPwKMoGstpfJVqr3aoinwKVPu4DLo9nQncbnuLk'\nListening on /ip4/127.0.0.1/tcp/57708/ws/p2p/12D3KooWRqAUEzPwKMoGstpfJVqr3aoinwKVPu4DLo9nQncbnuLk/p2p-circuit/p2p/12D3KooW9wFiWFELqGJTbzEwtByXsPiHJdHB8n7Kin71VMYyERmC/p2p-circuit/webrtc/p2p/12D3KooW9wFiWFELqGJTbzEwtByXsPiHJdHB8n7Kin71VMYyERmC\nDialing '/ip4/127.0.0.1/tcp/57708/ws/p2p/12D3KooWRqAUEzPwKMoGstpfJVqr3aoinwKVPu4DLo9nQncbnuLk/p2p-circuit/p2p/12D3KooWBZyVLJfQkofqLK4op9TPkHuUumCZt1ybQrPvNm7TVQV9/p2p-circuit/webrtc/p2p/12D3KooWBZyVLJfQkofqLK4op9TPkHuUumCZt1ybQrPvNm7TVQV9'\nSending message 'helloa'\nReceived message 'helloa'\nReceived message 'hellob'\n```\n\n`Browser B`\n```text\nDialing '/ip4/127.0.0.1/tcp/57708/ws/p2p/12D3KooWRqAUEzPwKMoGstpfJVqr3aoinwKVPu4DLo9nQncbnuLk/p2p-circuit/p2p/12D3KooW9wFiWFELqGJTbzEwtByXsPiHJdHB8n7Kin71VMYyERmC/p2p-circuit/webrtc/p2p/12D3KooW9wFiWFELqGJTbzEwtByXsPiHJdHB8n7Kin71VMYyERmC'\nListening on /ip4/127.0.0.1/tcp/57708/ws/p2p/12D3KooWRqAUEzPwKMoGstpfJVqr3aoinwKVPu4DLo9nQncbnuLk/p2p-circuit/p2p/12D3KooWBZyVLJfQkofqLK4op9TPkHuUumCZt1ybQrPvNm7TVQV9/p2p-circuit/webrtc/p2p/12D3KooWBZyVLJfQkofqLK4op9TPkHuUumCZt1ybQrPvNm7TVQV9\nReceived message 'helloa'\nSending message 'hellob'\nReceived message 'hellob'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaschad%2Ftest-js-libp2p-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaschad%2Ftest-js-libp2p-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaschad%2Ftest-js-libp2p-example/lists"}