Headless electron app platform for the cloud 🤕☁✨
We needed a way to run chrome-based browser experiences inside a container, and to stream that container to remote clients using webrtc. Browserd (named to indicate it's a browser daemon) uses electron to do so.
This app is broken down into two main components the stream-provider which contains and provides the 'browser experiences' and the stream-consumer an example of a 'remote client'. These components are supported by the shared component which houses shared functionality.
This simple web app connects to the stream-provider through a signaling server. It receives and displays a stream from the cloud, and it can send input to the cloud.
This electron app connects to the stream-consumer through a signaling server. It receives input from the consumer, and streams its view to the consumer.
We use Lerna to help manage our monorepo. It links our local dependencies and it reduces redundant packages and ensures consistent versioning. To run anything locally, you will need to npm install Lerna globally. With Lerna, we can automatically install all node_modules for all components, cross link them, and move shared dependencies up to the root.
npm install -g lerna
Our service is compatible with any standard WebRTC signaling implementation. If you need a simple one that communicates over HTTP/1.1, webrtc-signal-http is a good option.
Our service can be configured using a dotenv file - .env
containing one environment variable
key and value per line. For example KEY=value
. Below are the possible options:
SERVICE_URL
(string) - the web service address (to render)TURN_URL
(string) - a turn addressTURN_USERNAME
(string) - a turn usernameTURN_PASSWORD
(string) - a turn password credentialPOLL_URL
(string) - a signaling server base addressPOLL_INTERVAL
(number) - a signaling poll interval in msHEIGHT
(number) - the window heightWIDTH
(number) - the window widthEXP_HIDE_STREAMER
(boolean) - experiment flag for hiding the streamer windowTWILIO_ACCOUNT_SID
(string) - a Twilio AccountSid required to get a Network Traversal Service TokenTWILIO_AUTH_TOKEN
(string) - a Twilio AuthToken required to get a Network Traversal Service Token
Our service supports both coturn and Twilio's STUN/TURN service.
In the dotenv file, if TWILIO_ACCOUNT_SID
and TWILIO_AUTH_TOKEN
values are set, our service will attempt to get a turn server from Twilio. Otherwise, you can leave them empty to use a stun server or coturn turn server.
Our service follows electron security guideline and enables the following behaviors:
- Enabling contextIsolation, which allows scripts running in the renderer to make changes to its javascript environment without worrying about conflicting with the scripts in the electron API or the preload script.
- Blocking mouse middle-clicking, which opens a new window and makes our remote input stop working.
- Disabling popup dialog for file downloading (when clicking on a link) so that it doesn't interfere with the streamer window.
- Displaying warning about using insecure http protocol or when the streamer window navigates to a new origin, which is different from the
SERVICE_URL
.
Note: Please refer the README of any component subdirectory for more detailed instructions.
Ensure you've installed dependencies (npm i
) before continuing.
Follow these steps to get browserd up and running:
Note:
npm run magic
will complete all these steps for you.
npm run bootstrap
- this runs lerna bootstrap to setup the project, installing dependencies as it goes.npm run build
- this builds all the packages needed to run.npm run start
- this starts thestream-provider
. Note that it requires some environment variable configuration, as mentioned above.
Coming soon. ✨
MIT