A modern React web application that connects to Spotify's API to search for music, create playlists, and manage your music collection with ease.
- Spotify Integration: Secure OAuth authentication with Spotify
- Music Search: Search Spotify's massive music library
- Playlist Management: Create, edit, and delete playlists
- Smart Save: Updates existing playlists instead of creating duplicates
- Real-time Updates: Automatic playlist refresh after changes
- Track Management: Add and remove tracks from playlists
- Responsive Design: Works on desktop and mobile devices
- Auto-token Refresh: Seamless background token management
- Node.js (v14 or higher)
- npm or yarn
- Spotify Developer Account
-
Clone the repository
git clone https://github.com/Ollieadams23/jamming.git cd jamming -
Install dependencies
npm install
-
Set up Spotify API
- Go to Spotify Developer Dashboard
- Create a new app
- Add
http://127.0.0.1:3000/public/index.htmlto Redirect URIs - Copy your Client ID to
src/util/spotify.js
-
Start the application
npm start
-
Open your browser Navigate to
http://localhost:3000
- Login: Click "Log in with Spotify" and authorize the app
- Search Music: Use the search bar on the right to find tracks
- Create Playlists:
- Click "+ New Playlist" to start fresh
- Or click on an existing playlist to edit it
- Add Tracks: Click the "+" button next to search results to add tracks
- Remove Tracks: Click the "-" button next to playlist tracks to remove them
- Save Changes: Click "Save to Spotify" (green tick appears when saved)
- Delete Playlists: Click the delete button next to save (for existing playlists)
- Left Panel: Your existing Spotify playlists
- Right Panel: Search functionality and playlist editor
- Loading Indicators: Shows when data is being fetched
- Green Tick: Indicates successful playlist save
jamming/
βββ public/
β βββ index.html
β βββ manifest.json
βββ src/
β βββ components/
β β βββ App/ # Main application logic
β β βββ Profile/ # User authentication & profile
β β βββ Playlist/ # Playlist display & editing
β β βββ SearchBar/ # Music search interface
β β βββ SearchResults/ # Search results display
β β βββ Track/ # Individual track component
β β βββ TrackList/ # Track list container
β βββ util/
β β βββ spotify.js # Spotify API integration
β βββ index.css # Global styles
β βββ index.js # App entry point
βββ README.md
- React 18: Frontend framework with hooks and class components
- Spotify Web API: Music data and playlist management
- OAuth 2.0 PKCE: Secure authentication without client secrets
- CSS3: Modern styling with flexbox and responsive design
- Local Storage: Token persistence and caching
npm start # Start development server
npm test # Run test suite
npm run build # Build for production
npm run eject # Eject from Create React App (not recommended)The app uses Spotify's OAuth 2.0 with PKCE (Proof Key for Code Exchange) for secure authentication:
- User clicks login β Redirected to Spotify
- User authorizes app β Redirected back with authorization code
- Code exchanged for access token β Token stored locally
- Token automatically refreshes before expiration
- API calls use Bearer token authentication
- Create: New playlists are created on Spotify
- Update: Existing playlists are modified (tracks added/removed)
- Delete: Playlists are removed from user's Spotify account
- Load: Click any playlist to load its tracks for editing
- Real-time search through Spotify's catalog
- Results include track name, artist, album
- Preview URLs available (when provided by Spotify)
- Centralized state in App component
- Real-time UI updates
- Optimistic UI updates with error handling
- Edit
src/util/spotify.js - Update
CLIENT_IDwith your Spotify app's client ID - Ensure redirect URI matches your Spotify app settings
- For production, update
REDIRECT_URIto your deployed URL
Create a .env file in the root directory:
REACT_APP_SPOTIFY_CLIENT_ID=your_client_id_here
REACT_APP_REDIRECT_URI=your_redirect_uri_herenpm run buildnpm install -g surge
npm run build
cd build
surge- Connect your GitHub repository
- Set build command:
npm run build - Set publish directory:
build - Update Spotify redirect URI to your deployed URL
Login doesn't work:
- Check CLIENT_ID in spotify.js
- Verify redirect URI in Spotify app settings
- Clear browser cache and localStorage
Playlists don't load:
- Check browser console for errors
- Verify Spotify app permissions include playlist scopes
- Try logging out and back in
Token expired errors:
- App should auto-refresh tokens
- If persisting, clear localStorage and re-login
Open browser Developer Tools β Console to see detailed logging during authentication and API calls.
user-read-private: Access user profile informationuser-read-email: Access user emailplaylist-read-private: Read private playlistsplaylist-read-collaborative: Read collaborative playlistsplaylist-modify-public: Modify public playlistsplaylist-modify-private: Modify private playlists
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
For support, email your-email@example.com or create an issue on GitHub.
Made with β€οΈ and React
