Simple WebRTC data channel for React.
npm install react-device-portal !npm type definitions
``bash`
npm install react-device-portal
It is expected that the package will be used on two different devices. Create for them two separate pages or apps. Let's call them App A and App B. Both apps will be linked by same room (e.g. 'my-test-room').
The first app will be a value provider or Input.
`jsx
const AppA = () => {
const [value, setValue] = useState(0)
useDevicePortalInput('my-test-room', value.toString())
return (
<>
Value: {value}
$3
The other app will be a value consumer or
Output. Every time input value in App A changes, the output in App B will be automatically updated.`jsx
const AppB = () => {
const { value } = useDevicePortalOutput('my-test-room') return (
<>
App B
Value: {value}
>
)
}
`Server used for WebRTC signaling
github.com/FilipChalupa/webrtc-signaling-server
Development
Run
`sh
npm ci
npm run dev
`and
`sh
npm run storybook
``