@lastfm-viewer/react
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

@lastfm-viewer/react

[!NOTE] This repository is now part of a monorepo if you want to start developing on it go to the original monorepo here

Homepage: lastfm-viewer.vercel.app

A React component to view recent scrobbles for a provided last.fm user, built with:

Quick start

Install it:

npm i @lastfm-viewer/react
# or
yarn add @lastfm-viewer/react
# or
pnpm add @lastfm-viewer/react
# or
bun i @lastfm-viewer/react

Use it

to start using the component you first need to get a last.fm API key from here, once you've done that just import the component and specify the username of the user you want to get scrobbling information from:

Please note that some users set their profile stats to private, so not every user is applicable, if you're using this component on your personal account just set your "Recent listening" stats to public here

import ReactLastFMViewer from "@lastfm-viewer/react";

function App() {
	return (
		<>
			<ReactLastFMViewer user="[username]" api_key="[API_KEY]" />
		</>
	);
}

Props:

user: string :

last.fm username

api_key: string :

your last.fm public api key

updateInterval?: number :

if you want to frequently fetch the user's listening info just specify the updateInterval prop. (milliseconds) (it takes a number that determines the update interval):

import ReactLastFMViewer from "@lastfm-viewer/react";

function App() {
	return (
		<>
			<ReactLastFMViewer
				user="[username]"
				api_key="[API_KEY]"
				updateInterval={20000} {/* 20 seconds */}
			/>
		</>
	);
}

[!CAUTION] setting the updateInterval prop to a low number might subject your api key for termination, to avoid this just use a higher more reasonable number.

mode?: ("dev" | "prod") = "dev" :

The default value for this prop is: "dev"

when using "dev" mode any error that haapens will be viewed with the following message above it:

Hello developer👋, please consider handling the following error before deployment:

Error during development

when using "prod" mode the error is shown as is:

Error during production

Package Sidebar

Install

npm i @lastfm-viewer/react

Weekly Downloads

26

Version

2.3.0

License

GPL-3.0

Unpacked Size

13.8 MB

Total Files

20

Last publish

Collaborators

  • zoasr