- Real-time Updates: Reflects what you are currently listening to on Spotify.
- Server-Side Caching: Uses in-memory caching (30s TTL) to reduce API calls and protect rate limits.
- SVG Rendering: Returns a crisp, lightweight SVG image that renders perfectly in GitHub Readmes.
- Dynamic Styling: Beautifully designed templates that look great in any theme.
- Easy Integration: Simple Markdown or HTML snippets for embedding.
- Secure Auth: Uses Spotify OAuth 2.0 with state verification to prevent CSRF.
- Deduplication: Automatically maps repeat logins to the same UID based on Spotify ID.
- Secure Sessions: Uses signed,
httpOnlycookies to protect user dashboards. - Multi-user Support: Generates unique UIDs for multiple users on the same instance.
- Authentication: Users visit the root URL and click "Connect Spotify". The service uses a
stateparameter to prevent CSRF attacks. - Authorization: The service handles the OAuth callback, fetches your Spotify profile, and checks if you already have an account.
- Storage: Tokens and your display name are stored securely in Google Cloud Firestore, keyed by a unique UID.
- Retrieval: When someone views your widget, the service fetches your current playing track from the Spotify API.
- Auto-Refresh: If the access token is expired, the service automatically uses the refresh token to get a new one before fetching playback data.
- Rendering: The service returns a responsive HTML/CSS template representing your "Now Playing" status.
This service allows users to provide their own Spotify Client ID and Secret, bypassing Spotify's developmental 25-user limit.
To use this widget on your profile:
- Visit the Spotify Developer Dashboard.
- Click Create app and give it a name (e.g., "My Profile Widget").
- In Settings, add the following Redirect URI:
https://spotify.beebombshell.com/callback(or your instance URL). - Copy your Client ID and Client Secret.
- Enter them on the Home Page to connect your account.
If you want to host your own instance of this service:
- Create a project in the Firebase Console.
- Enable Firestore Database.
- Go to Project Settings > Service Accounts and generate a new private key (JSON).
git clone https://github.com/BeeBombshell/spotify-now-playing.git
cd now-playing
npm installCreate a .env file from .env.example:
| Variable | Description |
|---|---|
SESSION_SECRET |
A secure random string for signing cookies. |
REDIRECT_URI |
The callback URL (e.g., https://your-domain.com/callback). |
FIREBASE_PROJECT_ID |
Your Firebase Project ID. |
FIREBASE_SERVICE_ACCOUNT |
Raw JSON or Base64 encoded Service Account key. |
PORT |
Port to run the server (default 3000). |
# Development mode
npm run dev
# Production mode
npm run build
npm startOnce the app is running:
- Navigate to your app URL (e.g.,
http://localhost:3000). - Click Connect Spotify and authorize the app.
- You will be redirected to a Dashboard containing your unique embed links.
Add this to your README.md:
[](https://your-service-url/now-playing?uid=YOUR_UID)The widget template is located in src/template.ts. You can easily modify the CSS and HTML structure to match your personal brand.
Created with ❤️ by BeeBombshell