CODE COMPONENT

Spotify "Now Playing"

Free

Spotify Now Playing Widget – Setup Guide

This guide will walk you through setting up the Spotify Now Playing widget you purchased, so it connects to your personal Spotify account and shows your current track on your Framer site.

What You Need

Step 1: Create a Spotify Developer App

  1. Go to https://developer.spotify.com/dashboard

  2. Log in and click "Create an App"

  3. Name it anything (e.g. Now Playing Widget)

  4. Add the following Redirect URI:

  5. Click Save

Step 2: Generate Your Refresh Token

  1. Visit this tool:

  2. Paste in your:

  3. Click "Get Token" and authorize your account

  4. Copy the refresh_token that appears

Keep this token private. It allows access to your playback status.

Step 3: Set Up a Free API with Glitch

  1. Go to https://glitch.com/ and click "New Project" → "Hello Express"

  2. Rename the default index.js file to server.js

  3. Open the .env file and paste:

  4. In the Glitch terminal, run:

  5. Replace all contents of server.js with the code below:

const express = require('express');
const fetch = require('node-fetch');
require('dotenv').config();

const app = express();
const port = process.env.PORT || 3000;

// Allow CORS so Framer can access it
app.use((req, res, next) => {
  res.setHeader("Access-Control-Allow-Origin", "*");
  next();
});

app.get('/now-playing', async (req, res) => {
  try {
    const auth = Buffer.from(`${process.env.CLIENT_ID}:${process.env.CLIENT_SECRET}`).toString('base64');

    const tokenRes = await fetch('https://accounts.spotify.com/api/token', {
      method: 'POST',
      headers: {
        Authorization: `Basic ${auth}`,
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      body: new URLSearchParams({
        grant_type: 'refresh_token',
        refresh_token: process.env.REFRESH_TOKEN,
      }),
    });

    const { access_token } = await tokenRes.json();

    const nowRes = await fetch('https://api.spotify.com/v1/me/player/currently-playing', {
      headers: { Authorization: `Bearer ${access_token}` },
    });

    if (nowRes.status === 204) return res.json({ playing: false });

    const song = await nowRes.json();

    res.json({
      id: song.item?.id,
      title: song.item?.name,
      artists: song.item?.artists.map(a => a.name),
      art: song.item?.album?.images?.[0]?.url,
      playing: song.is_playing,
    });
  } catch (err) {
    console.error(err);
    res.status(500).json({ error: "Something went wrong" });
  }
});

app.listen(port, () => console.log(`Listening on port ${port}`));

  1. Click "Show" → "In a New Window"

  2. Copy the live URL (e.g. https://your-project-name.glitch.me/now-playing)

Step 4: Plug Into Framer

  1. Drag the Spotify Widget into your Framer project

  2. In the right-hand panel, paste your full API URL into the API Endpoint field:

  3. Preview your site – it should now show:

Extra Features (Optional)

  • Add vinyl rotation when playing === true

  • Add click-through to Spotify track link

  • Show last played song when nothing is currently playing

Let me know if you'd like these included in future versions!



People also like…

Get components and code overrides used in actual client projects. Save time building better Framer sites.

Join our mailing list

Get notified about new components as soon as they drop

You've been subscribed!

© Copyright 2025 AGR BLOCKS

Get components and code overrides used in actual client projects. Save time building better Framer sites.

Join our mailing list

Get notified about new components as soon as they drop

You've been subscribed!

© Copyright 2025 AGR BLOCKS