React Web Audio Toolkit

Browser tones and sweeps without fighting AudioContext.

webaudio-kit is a small React + TypeScript package set for tone generators, frequency sweeps, safe volume defaults, and analyser-driven UI in browser prototypes.

$pnpm add @webaudio-kit/react @webaudio-kit/core
webaudio-kit demo showing tone controls and waveform analyser
30-second setup

Wrap the app, then call a hook.

The public API stays intentionally small for the first production release.

App.tsx
import { AudioProvider, useTone } from "@webaudio-kit/react";

function ToneButton() {
  const tone = useTone({ frequency: 440, gain: 0.15, type: "sine" });

  return (
    <button type="button" onClick={() => void tone.play({ durationMs: 600 })}>
      Play 440 Hz
    </button>
  );
}

export function App() {
  return (
    <AudioProvider>
      <ToneButton />
    </AudioProvider>
  );
}
Packages

Narrow packages with clear ownership.

@webaudio-kit/core

Browser-safe playback helpers, math utilities, frequency clamping, and per-call node cleanup.

@webaudio-kit/react

AudioProvider plus hooks for tones, sweeps, master volume, context state, and analyser access.

apps/demo

A Vite React sandbox for manually testing tone generation, sweeps, pan, gain, and waveform output.

Manual proof

The demo exercises the real provider graph.

Tone and sweep nodes feed the master gain, analyser, then destination. The waveform should move while sound is playing.

No import-time AudioContext

AudioContext is created lazily after user interaction so React apps avoid browser autoplay violations.

Safe first-run volume

The provider starts with a 0.2 master gain and examples keep gain controls bounded.

Visible analyser signal

The demo draws analyser data so developers can verify the provider graph is live.

Release smoke checks

Package tarballs are built and reinstalled before publish so exports match the public API.

local verification
$ pnpm verify
tests pass
types pass
packages build
demo and site build
lint and format pass

Browser audio prototype, not medical software.

webaudio-kit can help build audible UI controls and prototypes. It is not certified audiology software, and it should not be used to diagnose hearing conditions or replace calibrated test equipment.