@lastfm-viewer/svelte
v5.0.1
Published
A Svelte component to view recent scrobbles for a last.fm user
Maintainers
Readme
@lastfm-viewer/svelte
[!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 sveltejs component to view recent scrobbles for a last.fm user
Quick start
Install it:
npm i @lastfm-viewer/svelte
# or
yarn add @lastfm-viewer/svelte
# or
pnpm add @lastfm-viewer/svelte
# or
bun i @lastfm-viewer/svelteInstall peer dependencies:
npm i -D @lastfm-viewer/ui @lastfm-viewer/utils
# or
pnpm i -D @lastfm-viewer/ui @lastfm-viewer/utils
# or
yarn add -D @lastfm-viewer/ui @lastfm-viewer/utils
# or
bun i -D @lastfm-viewer/ui @lastfm-viewer/utilsUse 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
<script>
import { SvelteLastFMViewer } from '@lastfm-viewer/svelte';
import '@lastfm-viewer/ui/styles';
import '@lastfm-viewer/ui/styles/LastFMViewer.css';
import '@lastfm-viewer/ui/styles/PastTracks.css';
import '@lastfm-viewer/ui/styles/TrackProgressBar.css';
import '@lastfm-viewer/ui/styles/CardFooter.css';
import '@lastfm-viewer/ui/styles/ErrorView.css';
</script>
<SvelteLastFMViewer user="[username]" />Props:
user: string :
last.fm username
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):
<script>
import { SvelteLastFMViewer } from "@lastfm-viewer/svelte";
</script>
<SvelteLastFMViewer
user="[username]"
updateInterval={20000} {/* 20 seconds */}
/>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:

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

