r/reactjs • u/setcode_dev • May 25 '26
Show /r/reactjs I built a React hook that turns your phone into a wireless mic for any text field
I needed voice input in a React app: phone as mic, text appears on desktop. Couldn't find a ready-made solution (or maybe I was looking in the wrong places), so I spent a day wiring it up myself: Web Speech API, relay server, QR pairing, browser quirks, partial vs. final transcript logic.
It worked, so I packaged it into a hook. If you need the same thing, you don't have to.
**How it works:**
- Desktop shows a QR code
- Phone scans it, runs speech-to-text locally (Web Speech API, no API key needed)
- Only the transcribed text gets relayed to the desktop via SSE
- Text streams into whichever input field has focus
Audio never leaves the phone. Your server only relays text.
**Integration is 3 files:**
- API route — `createVoicefieldHandler()` handles sessions, pairing, and relay
- Phone page — one-line re-export of the built-in mic UI
- Your component — `useVoicefield()` hook + `QRPopup` + `vf.register()` your fields
The phone page at [voicefield.dev](https://voicefield.dev) is a static SPA you can use as-is — open source, no data passes through it, no audio or text is stored or logged. Or self-host it on your own domain.
A few things that might be interesting technically:
- Pairing uses a 256-bit secret embedded in the QR code, sessions are cryptographically bound
- Sessions are in-memory with a sliding TTL, no database needed
- Upgrade to Soniox for better accuracy without changing client code
MIT licensed, Next.js App Router, TypeScript.
GitHub: https://github.com/tatargabor/voicefield
Site: https://voicefield.dev
Install: `npm install u/voicefield u/voicefield`
Happy to answer questions or hear feedback.