Quickstart (5 minutes)
What are we going to do?
Create real-time text editor between two peers.
- Account setup.
- Run a demo locally.
Let’s get started.
1. Your Account
Sign up for a PulseBeam account and get an api_key
and api_secret
.
- Go to cloud.pulsebeam.dev
- Login / create and account
- Create a project, name your project.
- Note: Plans are scoped to a project. Your project is Sandbox (free) by default until you change it. Contact us to change it.
- Create a keypair on your project, give your keypair a name, e.g. demokey
- Store those keys! You will not be able to access the private key again (but if you lose it or want to rotate, feel free to delete and recreate keys)
2. Serve it
Now that you’ve created your account and obtained your keys, let’s set up your local development environment.
You will need npm
and node.js
installed on your system. If you don’t have them, see their installation instructions
Pull down the project:
git clone git@github.com:PulseBeamDev/pulsebeam-js.gitcd pulsebeam-js/demo-cdn
Open index.html
in your editor of choice and replace these lines with your key:
apiKey: "kid_<...>",apiSecret: "sk_<...>",
Run demo locally with:
npm inpm run start
You should now have a server running locally on port 3000
3. See it
- Go to your browser open two tabs:
- URL for first tab: localhost:3000/?development=true&peerId=peer-29
- URL for second tab: localhost:3000/?development=true
- On the second tab enter peer-29 in the first text box. Then click connect.
- Type text in the bottom text box in either tab. Changes will synchronize between peers in real-time using WebRTC data channels.
Here’s what you should see:
Congratulations!
You’ve set up a real-time peer-to-peer connection using PulseBeam.
Next steps:
- Learn: What happened?.
- Explore the logs
- Experiment with the demo
Other Demos
Google Meet Clone
Check it out live: https://meet.pulsebeam.dev/
Read the source: https://github.com/PulseBeamDev/pulsebeam-js/tree/main/demo-react
Troubleshooting
- Check browser console, network tab, make sure your application received a valid auth token. Your request/response should look something like:
{"request": {"method": "POST","url": "https://cloud.pulsebeam.dev/sandbox/token",},"response": {"status": 200,"content": {"text": "eyJhbGciOiJFZERTQSIsImtpZCI6ImtpZF8wZGZhNTY5YjEwODUwYTVhIn0.eyJleHAiOjE3Mzg3OTQzMTMsImdpZCI6ImRlZmF1bHQiLCJwaWQiOiJwZWVyLTg2IiwiYXAiOnsiZ3JvdXBfaWQiOiIqIiwicGVlcl9pZCI6IioifX0.MOdiTUebb_n-WiAV8_2UiaA2YO8JvenQ0J9wkU7_wEtVHli_ySTM51u4SHMtpjgkjHuY70OjPrGpM-Daj7UMAg"},},},
- If your response is something like:
Status code 500
Something went wrong: failed to create sandbox token
Check your keys inindex.html
- The token is the text in the response (example above). You can decode it to inspect further. When you decode it, you should see something like:
Note: Your decoder may throw an “invalid signature” error when it does not support the algorithm of the token. We currently use EdDSA, which is fairly new (and well regarded).{"header": {"alg": "EdDSA","kid": "kid_0dfa569b10850a5a"},"payload": {"exp": 1738794313,"gid": "default","pid": "peer-86","ap": {"group_id": "*","peer_id": "*"}}}
- Port 3000 is already in use (
Error: listen EADDRINUSE: address already in use :::3000
) close other process or change port. - Something odd? Check you node version with
node -v
andnpm -v
. If older than 23.5.0 & 11.0.0 trynvm use node
ornvm use 23.5
- Something else? Checkout logs in browser console or contact us!