npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rewbs/wavesurfer.js

v8.0.0-beta.1

Published

Audio waveform player - temporary fork for experiments

Readme

wavesurfer.js

npm sponsor

Wavesurfer.js is an interactive waveform rendering and audio playback library, perfect for web applications. It leverages modern web technologies to provide a robust and visually engaging audio experience.

Gold sponsor 💖 Closed Caption Creator

🎉 v8 Beta Available! Try the new reactive streams and state management features. Learn more →

Table of contents

  1. Getting started
  2. What's new in v8
  3. API reference
  4. Plugins
  5. CSS styling
  6. Frequent questions
  7. Contributing
  8. Tests
  9. Feedback

Getting started

Install and import the package:

npm install wavesurfer.js
import WaveSurfer from 'wavesurfer.js'

Alternatively, insert a UMD script tag which exports the library as a global WaveSurfer variable:

<script src="https://unpkg.com/wavesurfer.js@7"></script>

Create a wavesurfer instance and pass various options:

const wavesurfer = WaveSurfer.create({
  container: '#waveform',
  waveColor: '#4F4A85',
  progressColor: '#383351',
  url: '/audio.mp3',
})

// Subscribe to events
wavesurfer.on('ready', () => {
  wavesurfer.play()
})

TypeScript types are included in the package, so there's no need to install @types/wavesurfer.js.

See more examples.

What's new in v8

v8 is 100% backward compatible – your existing code works without changes!

Reactive Event Streams

Subscribe to events with powerful stream operators:

// Debounce time updates for better performance
wavesurfer.getEventStream('timeupdate')
  .debounce(100)
  .subscribe(time => {
    updateUI(time)
  })

// Chain multiple operators
wavesurfer.getEventStream('timeupdate')
  .filter(() => wavesurfer.isPlaying())
  .throttle(1000)
  .map(time => Math.floor(time))
  .distinct()
  .subscribe(time => {
    console.log(`Second ${time}`)
  })

State Management

React to application state changes:

// Subscribe to playing state
wavesurfer.state
  .select(s => s.playback.isPlaying)
  .subscribe(isPlaying => {
    button.textContent = isPlaying ? 'Pause' : 'Play'
  })

// Combine multiple state values
wavesurfer.state
  .selectMany(
    s => s.playback.currentTime,
    s => s.audio.duration
  )
  .subscribe(([time, duration]) => {
    const progress = (time / duration) * 100
    updateProgressBar(progress)
  })

Available Stream Operators

  • map(fn) – Transform values
  • filter(fn) – Filter values
  • debounce(ms) – Debounce updates
  • throttle(ms) – Throttle updates
  • distinct() – Only emit unique values
  • take(n) – Take first n emissions
  • takeUntil(notifier) – Take until another stream emits

Try the beta:

npm install wavesurfer.js@beta

Learn more:

API reference

See the wavesurfer.js documentation on our website:

For v8 features, see the v8 API Reference.

Plugins

We maintain a number of official plugins that add various extra features:

  • Regions – visual overlays and markers for regions of audio
  • Timeline – displays notches and time labels below the waveform
  • Minimap – a small waveform that serves as a scrollbar for the main waveform
  • Envelope – a graphical interface to add fade-in and -out effects and control volume
  • Record – records audio from the microphone and renders a waveform
  • Spectrogram – visualization of an audio frequency spectrum (written by @akreal)
  • Hover – shows a vertical line and timestamp on waveform hover

To import a plugin (v7):

import Regions from 'wavesurfer.js/dist/plugins/regions.esm.js'

Or as a script tag:

<script src="https://unpkg.com/wavesurfer.js@7/dist/plugins/regions.min.js"></script>

CSS styling

wavesurfer.js v7 is rendered into a Shadow DOM tree. This isolates its CSS from the rest of the web page. However, it's still possible to style various wavesurfer.js elements with CSS via the ::part() pseudo-selector. For example:

#waveform ::part(cursor):before {
  content: '🏄';
}
#waveform ::part(region) {
  font-family: fantasy;
}

You can see which elements you can style in the DOM inspector – they will have a part attribute. See this example to play around with styling.

Questions

Have a question about integrating wavesurfer.js on your website? Feel free to ask in our Discussions forum.

However, please keep in mind that this forum is dedicated to wavesurfer-specific questions. If you're new to JavaScript and need help with the general basics like importing NPM modules, please consider asking ChatGPT or StackOverflow first.

FAQ

Contributing

We welcome contributions! Here's how to get started:

Development Setup

  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev

This command will start the Vite dev server with live reload at http://localhost:5173.

  1. Run tests:
npm test

Plugin Development

Interested in building plugins for wavesurfer.js? Check out our comprehensive guides:

Project Structure

wavesurfer.js/
├── src/
│   ├── streams/          # Reactive streams
│   ├── state/            # State management
│   ├── core/             # Pure functions
│   ├── plugins/          # Plugin system
│   └── ...               # Core components
├── examples/             # Example files
└── docs/                 # Documentation

Tests

The project uses Vitest for unit tests and Cypress for e2e/visual regression tests.

Running Unit Tests

npm test

Running E2E Tests

First build the project:

npm run build

Then launch the tests:

npm run cypress

Feedback

We appreciate your feedback and contributions!

If you encounter any issues or have suggestions for improvements, please don't hesitate to post in our forum.

We hope you enjoy using wavesurfer.js and look forward to hearing about your experiences with the library!


License: BSD-3-Clause

Made with ♥ by the wavesurfer.js community