https://github.com/substrate-system/webrtc
Simple webrtc
https://github.com/substrate-system/webrtc
Last synced: about 1 year ago
JSON representation
Simple webrtc
- Host: GitHub
- URL: https://github.com/substrate-system/webrtc
- Owner: substrate-system
- License: other
- Created: 2025-01-13T00:30:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-12T02:38:56.000Z (over 1 year ago)
- Last Synced: 2025-02-12T03:30:05.806Z (over 1 year ago)
- Language: TypeScript
- Size: 106 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# webrtc
[](README.md)
[](https://semver.org/)
[](./CHANGELOG.md)
[](LICENSE)
Webrtc for humans.
The example code depends on cloudflare as a STUN/TURN server.
To run the demo, you will need to create a cloudflare account
and [generate credentials](https://developers.cloudflare.com/calls/turn/generate-credentials/).
Contents
- [install](#install)
- [Modules](#modules)
* [ESM](#esm)
* [Common JS](#common-js)
* [pre-built JS](#pre-built-js)
- [use](#use)
* [JS](#js)
- [develop](#develop)
* [`.dev.vars`](#devvars)
* [start a local server](#start-a-local-server)
## install
```sh
npm i -S @substrate-system/webrtc
```
## Modules
This exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).
### ESM
```js
import { webrtc } from '@substrate-system/webrtc'
```
### Common JS
```js
const webrtc = require('@substrate-system/webrtc/module')
```
### pre-built JS
This package exposes minified JS files too. Copy them to a location that is
accessible to your web server, then link to them in HTML.
#### copy
```sh
cp ./node_modules/@substrate-system/webrtc/dist/index.min.js ./public/webrtc.min.js
```
#### HTML
```html
```
## use
### JS
```js
import { webrtc } from '@substrate-system/webrtc'
```
## develop
Start a local websocket server and also a `vite` server for the front-end:
To run the example, you will need to create a cloudflare account
and [generate credentials](https://developers.cloudflare.com/calls/turn/generate-credentials/). Paste the credentials into `.dev.vars`.
### `.dev.vars`
```sh
# .dev.vars
NODE_ENV="development"
DEBUG="*"
CF_TURN_NAME="my-server-name"
CF_TURN_TOKEN_ID="123abc"
CF_TURN_API_TOKEN="123bc"
```
### start a local server
```sh
npm start
```