waves-cn is fully compatible with every official wavesurfer.js plugin. There are two injection patterns depending on when the plugin needs to be registered:
Pattern
When to use
plugins prop / option
Plugin must exist at instance creation time (e.g. ZoomPlugin, TimelinePlugin, SpectrogramPlugin)
onReady / useEffect
Plugin requires the instance to already exist (e.g. RecordPlugin)
Pass a memoized array to the plugins prop. The player and hook use array reference equality to decide whether to recreate the instance — a new array on every render will destroy and recreate the waveform on every render.
The instances you pass are templates. wavesurfer.js destroys plugins together with the instance, so waves-cn clones each template every time it (re)creates the instance. Put plugin option props in the useMemo deps to have option changes applied, and look the live plugin up after ready with ws.getActivePlugins() rather than holding on to the template.
Some plugins like RecordPlugin need to be registered after the instance is ready. Use onReady with WavesurferPlayer, or useEffect on wavesurfer with the hook.
Plugin events are accessed imperatively via wavesurfer.on() or through the plugin instance itself. Subscribe inside a useEffect so the listener is removed when the instance is recreated. With WavesurferPlayer, grab the instance in onReady, store it in state, and subscribe in an effect: