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

playbar

v1.0.0

Published

A drop-in Spotify-style music player component for any website

Readme

Playbar 🎵

A drop-in Spotify-style music player component that works on any website, regardless of framework.

Features

  • 🎨 Spotify-style UI - Beautiful dark theme with glassmorphism effects
  • 🎯 Framework-agnostic - Works with React, Vue, Angular, or vanilla HTML
  • 🔒 Style isolation - Uses Shadow DOM to prevent CSS conflicts
  • 📦 Two integration methods - Script tag or npm package
  • Auto-initialization - Just add data attributes and it works
  • 🎛️ Full API - Programmatic control over playback

Installation

Option 1: Script Tag

<script src="https://unpkg.com/playbar/dist/playbar.umd.js"></script>

Option 2: NPM

npm install playbar

Usage

Script Tag (Auto-initialization)

Add the script and use data attributes for automatic initialization:

<script src="playbar.umd.js"></script>

<div 
  data-playbar
  data-src="path/to/audio.mp3"
  data-title="Song Title"
  data-artist="Artist Name"
  data-artwork="path/to/cover.jpg"
></div>

JavaScript API

Create players programmatically with full control:

import { Playbar } from 'playbar';

const player = new Playbar('#container', {
  src: 'audio.mp3',
  title: 'Song Title',
  artist: 'Artist Name',
  artwork: 'cover.jpg',
  autoplay: false,
  volume: 0.8
});

// Control playback
player.play();
player.pause();
player.setVolume(0.5);
player.seekTo(30); // seconds

// Update track
player.setTrack({
  src: 'new-audio.mp3',
  title: 'New Song'
});

// Cleanup
player.destroy();

React Example

import { useEffect, useRef } from 'react';
import { Playbar } from 'playbar';

function Player({ track }) {
  const containerRef = useRef(null);
  const playerRef = useRef(null);

  useEffect(() => {
    playerRef.current = new Playbar(containerRef.current, track);
    return () => playerRef.current?.destroy();
  }, []);

  useEffect(() => {
    playerRef.current?.setTrack(track);
  }, [track]);

  return <div ref={containerRef} />;
}

Vue Example

<template>
  <div ref="playerContainer"></div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import { Playbar } from 'playbar';

const playerContainer = ref(null);
let player = null;

onMounted(() => {
  player = new Playbar(playerContainer.value, {
    src: 'audio.mp3',
    title: 'Song Title',
    artist: 'Artist Name'
  });
});

onUnmounted(() => player?.destroy());
</script>

API Reference

Constructor

new Playbar(container: HTMLElement | string, options: PlaybarOptions)

Options:

| Property | Type | Required | Description | |----------|------|----------|-------------| | src | string | Yes | Audio file URL | | title | string | Yes | Track title | | artist | string | Yes | Artist name | | artwork | string | No | Album artwork URL | | autoplay | boolean | No | Auto-play on init (default: false) | | volume | number | No | Initial volume 0-1 (default: 1) |

Methods

| Method | Description | |--------|-------------| | play() | Start playback | | pause() | Pause playback | | setVolume(vol) | Set volume (0-1) | | seekTo(time) | Seek to time in seconds | | setTrack(options) | Update track info | | destroy() | Clean up player |

Data Attributes

For auto-initialization, use these attributes on your container element:

| Attribute | Description | |-----------|-------------| | data-playbar | Required. Marks element for auto-init | | data-src | Audio file URL | | data-title | Track title | | data-artist | Artist name | | data-artwork | Album artwork URL | | data-autoplay | Set to "true" for autoplay |

Building from Source

# Install dependencies
npm install

# Build for production
npm run build

# Watch mode for development
npm run dev

License

MIT