OJPARKINSON / use-last-fm

๐ŸŽธ React Hook to use realtime last.fm data and display your currently played song in your application.

Home Page:https://npmjs.com/package/use-last-fm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use-last-fm

CI Status

Stream your currently playing song through last.fm as a React hook.

Features

  • ๐Ÿ“ฆ Tiny: use-last-fm weighs in at less than 700 bytes minified and gzipped.
  • ๐ŸŒณ Universal: we dist esm and cjs modules.
  • ๐Ÿ‘จโ€๐Ÿ’ป Developer friendly: Helpful development messages that are stripped away in production
  • โŒจ๏ธ Strongly typed: use-last-fm is written in TypeScript and encourages good practices this way

Installation

With NPM

npm i --save use-last-fm

Or, with yarn:

yarn add use-last-fm

Usage

import { useLastFM } from 'use-last-fm';

const CurrentlyPlaying = () => {
  const lastFM = useLastFM('aabbccsmith', '[add api token here]');

  if (lastFM.status !== 'playing') {
    return <p>Not listening to anything</p>;
  }

  return (
    <p>
      Listening to {lastFM.song.name} by {lastFM.song.artist}
    </p>
  );
};

A full example can be seen in the examples folder

About

๐ŸŽธ React Hook to use realtime last.fm data and display your currently played song in your application.

https://npmjs.com/package/use-last-fm

License:MIT License


Languages

Language:TypeScript 93.0%Language:HTML 7.0%