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

@lastfm-viewer/svelte

v2.0.4

Published

A Svelte component to view recent scrobbles for a last.fm user

Downloads

38

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/svelte

Initialize tailwind config:

npx @lastfm-viewer/ui init
# or
pnpm dlx @lastfm-viewer/ui init
# or
yarn dlx @lastfm-viewer/ui init
# or
bunx @lastfm-viewer/ui init

Install peer dependencies:

npm i -D @lastfm-viewer/utils @lastfm-viewer/tailwind-config @lastfm-viewer/ui @iconify/svelte @fontsource/inter
# or
pnpm i -D @lastfm-viewer/utils @lastfm-viewer/tailwind-config @lastfm-viewer/ui @iconify/svelte @fontsource/inter
# or
yarn add -D @lastfm-viewer/utils @lastfm-viewer/tailwind-config @lastfm-viewer/ui @iconify/svelte @fontsource/inter
# or
bun i -D @lastfm-viewer/utils @lastfm-viewer/tailwind-config @lastfm-viewer/ui @iconify/svelte @fontsource/inter

[!NOTE] If you're installing the component inside an Astro project do this instead:

npm install @astrojs/tailwind tailwindcss
# or
pnpm add @astrojs/tailwind tailwindcss
# or
yarn add @astrojs/tailwind tailwindcss

Inside astro.config.mjs add the css nesting option:

import { defineConfig } from 'astro/config';

export default defineConfig({
	integrations: [
		// ...
		tailwind({
			nesting: true
		})
		// ...
	]
});

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

<script>
	import SvelteLastFmViewer from '@lastfm-viewer/svelte/SvelteLastFMViewer.svelte';
</script>

<SvelteLastFmViewer 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):

<script>
	import SvelteLastFmViewer from "@lastfm-viewer/svelte/SvelteLastFMViewer.svelte";
</script>

<SvelteLastFmViewer
	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