Build against packed packages.
The examples are outside the pnpm workspace on purpose. The checker copies each one into a temporary folder, installs packed package tarballs, and runs the example build.
Check examples
pnpm examples:checkRun in browser
These links open standalone GitHub example folders in StackBlitz or CodeSandbox. The repository remains the source of truth, so the browser examples follow the same package files that CI checks. You can also import the repo on Replit.
Vite React starter
Tone, sweep, noise, volume, waveform, and spectrum controls in a small Vite app.
Next App Router starter
Server/client boundary example for AudioProvider, hooks, and visualizer canvases.
Incident Alert Console
Product-style monitoring console with severity cues, volume control, context state, and analyser output.
Audio test mode
Safe diagnostic sequence for tone, pan, sweep, noise, and analyser checks.
Vite React
Main tone, sweep, noise, volume, waveform, and spectrum example for client-side React apps.
cd examples/vite-react
pnpm install
pnpm devfunction AudioWorkbench() {
const [frequency, setFrequency] = useState(440);
const tone = useTone({ frequency, gain: dbToGain(-18), type: "sine" });
const sweep = useFrequencySweep({ from: 250, to: 8000, durationMs: 2400 });
const noise = useNoise({ durationMs: 700, gain: 0.07, type: "pink" });
const volume = useVolume();
return (
<>
<button onClick={() => void tone.play()}>Play tone</button>
<button onClick={() => void sweep.play()}>Run sweep</button>
<button onClick={() => void noise.play()}>Pink noise</button>
<input
max="0.5"
min="0"
onChange={(event) => void volume.setGain(event.currentTarget.valueAsNumber)}
type="range"
value={volume.gain}
/>
<WaveformCanvas backgroundColor="#10110f" strokeColor="#c8ea3a" />
<SpectrumCanvas backgroundColor="#10110f" barColor="#8ed8ff" />
</>
);
}
createRoot(document.getElementById("root")!).render(
<AudioProvider>
<AudioWorkbench />
</AudioProvider>,
);Next App Router
Server page with a client component boundary for AudioProvider, hooks, and visualizer canvases.
cd examples/next-app-router
pnpm install
pnpm dev"use client";
import {
AudioProvider,
SpectrumCanvas,
WaveformCanvas,
useFrequencySweep,
useNoise,
useTone,
useVolume,
} from "@webaudio-kit/react";
function Controls() {
const tone = useTone({ frequency: 440, gain: 0.14, type: "sine" });
const sweep = useFrequencySweep({ from: 250, to: 8000, durationMs: 2400 });
const noise = useNoise({ durationMs: 700, gain: 0.07, type: "pink" });
const volume = useVolume();
return (
<section aria-label="Browser audio controls">
<button onClick={() => void tone.play({ durationMs: 700 })}>
Play 440 Hz
</button>
<button onClick={() => void sweep.play()}>Run sweep</button>
<button onClick={() => void noise.play()}>Pink noise</button>
<input
max="0.5"
min="0"
onChange={(event) => void volume.setGain(event.currentTarget.valueAsNumber)}
step="0.01"
type="range"
value={volume.gain}
/>
<WaveformCanvas />
<SpectrumCanvas />
</section>
);
}
export function AudioControls() {
return (
<AudioProvider>
<Controls />
</AudioProvider>
);
}Plain React
Smallest provider, tone, volume, waveform, and spectrum setup.
cd examples/plain-react
pnpm install
pnpm devfunction App() {
const tone = useTone({ frequency: 440, gain: 0.14, type: "sine" });
const volume = useVolume();
return (
<AudioProvider>
<button onClick={() => void tone.play({ durationMs: 600 })}>
Play tone
</button>
<input
max="0.5"
min="0"
onChange={(event) => void volume.setGain(event.currentTarget.valueAsNumber)}
type="range"
value={volume.gain}
/>
<WaveformCanvas />
<SpectrumCanvas />
</AudioProvider>
);
}Incident Alert Console
Product-style monitoring console with severity cues, master volume, audio state, waveform, and spectrum output.
cd examples/incident-alert-console
pnpm install
pnpm devfunction IncidentConsole() {
const audio = useAudioContext();
const warningTone = useTone({ frequency: 880, gain: 0.11 });
const criticalSweep = useFrequencySweep({
durationMs: 700,
from: 520,
to: 1800,
type: "sawtooth",
});
function stopAllLocalCues() {
audio.stopAll();
}
return (
<section aria-label="Audio runtime controls">
<button onClick={() => void audio.ensureAudioContext()}>
Enable audio
</button>
<button onClick={() => void warningTone.play()}>Warning cue</button>
<button onClick={() => void criticalSweep.play()}>Critical cue</button>
<button onClick={stopAllLocalCues}>Stop cues</button>
<WaveformCanvas idleStrokeColor="#384235" />
<SpectrumCanvas idleBarColor="#384235" />
</section>
);
}Audio test mode
Low-gain diagnostic sequence with analyser output and manual stop controls.
cd examples/audio-test-mode
pnpm install
pnpm devfunction AudioSelfCheck() {
const testMode = useAudioTestMode();
return (
<AudioProvider>
<p>{testMode.currentStep?.label ?? "Idle"}</p>
<button onClick={() => void testMode.run()}>Run test mode</button>
<button onClick={testMode.stop}>Stop</button>
<WaveformCanvas />
<SpectrumCanvas />
</AudioProvider>
);
}