Challenge
Five minutes to a live connection
Fresh Vite project. Real PeerKit SDK. Real phone QR. Real timer.
Download the example or recreate it from Vite. The API key stays on a tiny Node server. This browser joins with @peerkit-dev/sdk@0.1.6. The phone opens the hosted invitation page.
Goal
From a fresh project, install @peerkit-dev/sdk@0.1.6, paste a small example, open a browser, scan a QR code with a phone, and establish a real PeerKit connection in about five minutes.
Exact commands
From a blank Vite app:
npm create vite@latest peerkit-challenge -- --template vanilla-ts cd peerkit-challenge npm install npm install @peerkit-dev/sdk@0.1.6 npm run dev
Or download the complete working example (server, UI, QR, timer, Camera / Audio / Data):
Download the five-minute challenge
unzip peerkit-five-minute-challenge.zip cd peerkit-five-minute-challenge cp .env.example .env # Paste PEERKIT_API_KEY from https://peerkit.dev/dashboard/keys npm install npm run dev
Open http://127.0.0.1:5173. Leave PEERKIT_API_URL=https://api.peerkit.dev.
Authentication
Create a server API key at API keys. Put it in .env as PEERKIT_API_KEY. The key starts with pk_live_ and must never appear in browser code, client bundles, or invitation URLs.
Participant tokens
The browser redeems an invitation secret for a short-lived participant token, then refreshes that token while the session is open. Neither step uses the API key.
Working example
Server session creation:
import { PeerKit } from "@peerkit-dev/sdk/server";
const peerkit = new PeerKit({
apiKey: process.env.PEERKIT_API_KEY!,
apiUrl: "https://api.peerkit.dev",
});
const session = await peerkit.createSession({ name: "Challenge" });
const phone = await peerkit.createInvitation(session.id, "publisher");
const browser = await peerkit.createInvitation(session.id, "viewer");Browser join with the SDK:
import { PeerKitSession } from "@peerkit-dev/sdk";
const redeemed = await fetch("/api/redeem", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ token: invitationToken }),
});
const access = await redeemed.json();
const session = new PeerKitSession({
signalingUrl: access.signalingUrl,
token: access.participantToken,
tokenExpiresAt: access.tokenExpiresAt,
});
session.attachVideo(videoElement);
await session.connect();Phone connection
- Click Start on the elapsed timer, choose Camera, Audio, or Data, then Create session.
- Scan the large QR code. The phone opens
https://peerkit.dev/swith the invitation in the fragment. - Allow camera or microphone permissions on the phone and join.
- Watch the desktop page connect with
PeerKitSession. The timer records the real time to first connection.
What each mode shows
- Camera — phone publishes; desktop watches remote video. Optional one-way phone microphone audio is not two-way talkback.
- Audio —
media: "audio"microphone-only call with mute and activity indication. - Data — text messages, file transfer with progress, accept, and download.
Troubleshooting
Missing PEERKIT_API_KEY— copy.env.exampleto.envand paste a key from the dashboard.concurrency_limited— Free plans allow one open session. End the previous session first.- QR will not scan — keep the invitation in the QR only. Do not log invitation URLs; the fragment is the secret.
- Browser connects but no video — on the phone, allow the camera and tap Start on the hosted join page.
- Audio silent — tap Hear the call and Turn on microphone after a user gesture on both sides.
Measured completion time
Validated on 15 October 2026 from a clean directory against production api.peerkit.dev with @peerkit-dev/sdk@0.1.6:
npm install→ listening app → Create session with QR and redeemable participant token: 4.5 seconds machine time (install 1.5s, server ready 3.2s).- Playwright walkthrough (camera, audio, data session creation, QR, local SDK join, cleanup): 4 passed in 12.4s.
Those numbers exclude account creation, API key pasting, and a physical phone scan. Use the on-page timer to record your own time to first real connection.
Automated walkthrough
Playwright creates real production sessions, asserts the QR, joins from Chromium with the SDK, writes screenshots and video under test-results/, and ends each session. It does not fake a WebRTC connection. It also cannot operate a physical phone camera.
npx playwright install chromium npm run test:e2e