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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-spotify-muse

v0.3.0

Published

A React component to display what you're listening to

Downloads

4

Readme

React Spotify Muse

Build Size Version

A small, simple, and clean React component to help you show others what you're listening to at the moment.

Installation

npm i react-spotify-muse

Usage

In order to display what you're currently listening to, you'll need a Spotify Web API OAuth token.

If you're unfamiliar with how to get a token, follow Spotify's Authorization Guide.

When you've successfully authenticated with the Spotify API, pass your token into the NowPlaying component.

OAuth tokens do expire after a period of time. When the token becomes expired, the onError event will emit an error object with the status value as 401. You can use this as a way to refresh your token, but it is preferable to keep track of the expires_in value associated with your token instead.

import React from 'react'
import { NowPlaying } from 'react-spotify-muse'

const App = () => {
  const token = 'aExjz492zo04uc...'

  return <NowPlaying token={token} />
}

Configuration

Polling

The default behavior will only fetch the currently playing track when the component is mounted. If you provide an updated token value, the component will re-fetch the currently playing track.

If you'd wish to have the component poll the API to display updated tracks over time, use the usePolling prop. The default polling rate is once every 2 minutes.

Styles

For simplicity, use the root element's ID value of rsm to override all styles.

#rsm {
  border: 1px solid #000;
}
#rsm .name {
  font-weight: normal;
}
#rsm .artist {
  color: #000;
}

License

Distributed under the MIT License. See LICENSE.txt for more information.

Built With