spotify-integration

star 79

Work on Spotify API, API routes, or Spotify UI. Use when modifying Spotify playback, playlists, profile, top artists/tracks, token refresh, normalization, or Spotify-related hooks and components.

mateonunez By mateonunez schedule Updated 3/7/2026

name: spotify-integration description: Work on Spotify API, API routes, or Spotify UI. Use when modifying Spotify playback, playlists, profile, top artists/tracks, token refresh, normalization, or Spotify-related hooks and components.

Spotify integration

Guidance for the Spotify feature (API, routes, hooks, and UI).

Server: client and cache

  • Client: lib/spotify.tsSpotifyClient class (token refresh, retries, timeout, in-memory cache). Uses env: SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, SPOTIFY_REFRESH_TOKEN.
  • OAuth: Refresh-token flow only; no user login on the site. Token is refreshed in getAccessToken() when expired.
  • Server-side dedup: All public getters are wrapped in React cache() so the same request deduplicates within one RSC request:
    • getCurrentlyListening, getRecentlyPlayed, getTopArtists, getTopTracks, getUserProfile, getUserPlaylists, getUserPublicPlaylists(userId, limit, offset).

API routes

Normalization

  • lib/utils/normalizers/index.ts — e.g. normalizeCurrentlyListening, normalizeArtists, normalizeTracks. Use these before sending API responses so the client gets a stable shape.

Client: hooks and SWR

UI and dynamic loading

Types

  • types/spotify.ts — API and normalized types (e.g. NormalizedSpotifyProfile, now-playing shape).

Adding a new endpoint or hook

  1. Add the method to SpotifyClient in lib/spotify.ts if it calls Spotify API; wrap the public getter in cache().
  2. Add route under app/api/spotify/; use normalizers for the response.
  3. Add or reuse a hook with SWR; throw in fetcher on !res.ok and surface isError in UI.
Install via CLI
npx skills add https://github.com/mateonunez/website --skill spotify-integration
Repository Details
star Stars 79
call_split Forks 10
navigation Branch main
article Path SKILL.md
More from Creator