If you want to share your love for music with the world you are in the right place. Show what's playing on your Spotify by posting the generated image!
πΈ playing now - current state of the playing track with real-time progress bar
π¬ ended state β when a track is ended, the badge transitions to this state
βΈ paused state - when the current track is paused in the player
π idle state β not playing
- Go to Spotify Developer Dashboard and log in with your Spotify account
- Click Create An App
- Fill in the name and description of a new app and click Create.
- Click Show Client Secret.
- Copy Client ID and Client Secret we will need it a bit later.
Important
Since early 2026, Spotify apps start in Development Mode, which comes with rules that directly affect this badge β see Spotify's Development Mode below before you go further. In short: the Spotify account that owns the app needs an active Premium subscription, and you'll need to redo the "Get Refresh Token" step below every so often, since refresh tokens now expire.
- Open this link for deploy app to Vercel
- Click Continue on Clone Git Repository screen
- Choose where you want to save code on Create Git Repository and Vercel will fork this repo automatically
- Click Continue on Import Project screen
- Put Client ID to
SPOTIFY_CLIENT_IDand Client Secret toSPOTIFY_CLIENT_SECRETand put just-toSPOTIFY_REFRESH_TOKEN. - If you plan to use API specify
API_CORS_HOSTas the host from which you plan to call the API endpoint. Read more - Click Deploy
- When an application is deployed go to Dashboard
- Copy your project's stable production domain (the one shown under the
Productionlabel β e.g.https://spotify-badge.vercel.app). Don't use one of the auto-generated preview/deployment URLs (the ones with a random hash in them likespotify-badge-c74hazo6k.vercel.app) β those change on every deploy, so registering one as your Redirect URI will break as soon as you redeploy. - Go back to Spotify Developer Dashboard
- Open application
- Click to Edit Settings
- Add path
/api/authto that production domain. It should look like thishttps://spotify-badge.vercel.app/api/auth. Screenshot - Put the url Redirect URI and click Add
- Save changes by clicking on Save at the end of the form
- Open a new tab on the browser and go to that same URL, e.g.
https://spotify-badge.vercel.app/api/auth - Copy Refresh token and put to the application settings on Vercel
- Go to the Deployments page and redeploy the last deployment of your application on Vercel
- Everything is done!
You can copy this snippet and change the domain in the URL to the domain of your application and post it wherever you would like
<img
src="https://spotify-playing-now-readme.vercel.app/api/now-playing.svg"
width="540"
height="52"
/>To make API available, specify API_CORS_HOST after you deploy the app.
- Open the created project on Vercel and go to Settings.
- Open tab Environment Variables
- Create a variable with the name
API_CORS_HOSTand put the site address from which you plan to make requests for examplehttps://example.com(the variable will be set toAccess-Control-Allow-Originheader. More about the header)
Response:
When something is playing
type Response =
/** When a track is playing */
{
progress: number;
duration: number;
track: string;
artist: string;
isPlaying: boolean;
coverUrl: string;
url: string;
}
/** When nothing is playing */
| {
isPlaying: false;
}Every new Spotify app starts in Development Mode, and since a February 2026 policy change this comes with rules that matter for a badge like this one:
- The app owner's Spotify account must have an active Premium subscription. If it lapses, the app stops authenticating β API calls will start failing until Premium is restored.
- Refresh tokens expire β your app's Client Secret page in the dashboard shows the current lifetime (commonly 180 days). When it expires, requests will fail with
invalid_grant, and you'll need to redo Get Refresh Token to mint a new one. - Development Mode apps are capped to a small number of authorized users and a limited number of Client IDs per developer account. For a personal badge with a single user (you), this isn't a practical limit.
- If you ever created more than one Spotify app for this project, double-check that the
SPOTIFY_CLIENT_ID/SPOTIFY_CLIENT_SECRETpair in Vercel matches the same app you authorized in Get Refresh Token. A refresh token only works with the app that issued it β mixing credentials from two different apps produces aninvalid_grant: Invalid refresh tokenerror that looks identical to an expired token.
None of this applies if your app is approved for Extended Quota Mode, but that requires a registered business and 250k+ monthly active users β not realistic for a personal project, so periodic token renewal is expected behavior here.
If the badge shows an idle/empty state even while something is playing:
- Check the deployed function's logs for the actual error:
vercel logs <your-production-domain>
lib/spotify.tslogs the real Spotify API response on any failure instead of silently returning an idle state. invalid_grant: Refresh token revokedorInvalid refresh tokenβ redo Get Refresh Token.- Otherwise, confirm the app's Premium requirement and Development Mode status in the Spotify Developer Dashboard.
- Copy
.env.exampleto.envand add values to env variables - Run
npm install -g pnpm@9if your globalpnpmisn't9.xyet (required by this project'senginesfield) - Run
pnpm installfor dependencies installation - Run
pnpm devto start a development server