A full-stack Notion Widget built with Next.js, Spotify API, and WebSockets to display real-time playback information inside Notion.
- Real-time song updates using WebSockets.
- OAuth authentication with Spotify API.
- Secure access & refresh token handling.
- Playback controls (play, pause, next, previous).
- Lightweight & embeddable in Notion.
- Frontend: React (Next.js)
- Backend: Next.js API routes (Node.js + Express-like server functions)
- Real-time Updates: Socket.io (WebSockets)
- Authentication: OAuth 2.0 with Spotify API
- Hosting: Vercel (Recommended)
- User logs in with Spotify (OAuth authentication flow).
- WebSocket server listens for song changes every 10s.
- Frontend listens to WebSocket updates in real time.
- Widget displays current track & allows playback control.
notion-spotify-widget/
│── components/
│ ├── SpotifyWidget.js # React widget UI
│── pages/
│ ├── api/
│ │ ├── login.js # Redirects to Spotify login
│ │ ├── callback.js # Handles Spotify OAuth callback
│ │ ├── now-playing.js # Fetches current track
│ │ ├── socket.js # WebSocket server
│ │ ├── play.js # Play song
│ │ ├── pause.js # Pause song
│ │ ├── next.js # Next song
│ │ ├── previous.js # Previous song
│ ├── index.js # Main UI page
│── public/
│── styles/
│── .env.local # API Keys (ignored by Git)
│── package.json # Dependencies
│── README.md # Project Overview
git clone https://github.com/tonydotdev/notion-spotify-widget.git
cd notion-spotify-widgetnpm installCreate a .env.local file and add:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=http://localhost:3000/api/callbacknpm run dev- Open
http://localhost:3000in your browser.
vercel deploy- Copy the public URL and embed it in Notion using
/embed.
- Dark mode support
- Song progress bar
This project is licensed under the MIT License.
Need help? Open an issue on GitHub! 🚀
