Overview
TheSoundCloudPlayer component provides a responsive iframe-based SoundCloud player with extensive customization options for appearance and behavior. It wraps the SoundCloud widget API with configurable controls for sharing, buying, and downloading.
Props
The public URL of the SoundCloud track (e.g.,
https://soundcloud.com/user/track-name)Height of the player in pixels. Default
166 is standard for the compact version.Width of the player. Defaults to
100% for responsive behavior.Controls iframe loading behavior. Use
lazy for below-the-fold players to improve page performance.Show or hide buy buttons in the player interface.
Show or hide share buttons in the player interface.
Show or hide download buttons in the player interface.
Player Configuration
The component includes several pre-configured SoundCloud widget parameters:- Color:
#d50000(red accent for play button and controls) - Auto-play: Disabled by default
- Related tracks: Hidden
- Comments: Shown
- User name: Shown
- Reposts: Hidden
- Artwork: Shown
- Play count: Shown
- Visual mode: Disabled (compact mode)
Usage Examples
Basic Track Embed
Lazy Loading with Custom Height
Enable Sharing and Download Options
Multiple Players on Page
The
single_active parameter is set to false, allowing multiple players on the same page to play independently without stopping each other.Styling
The component includes built-in Tailwind CSS classes for styling:- Container:
mx-auto w-full max-w-4xl(centered, responsive, max-width constraint) - Rounded corners:
rounded-xl - Shadow:
shadow-xl - Overflow handling:
overflow-hidden
Performance Considerations
Optimization Tips
- Lazy loading: Set
loading="lazy"for tracks not immediately visible - Limit count: Avoid embedding too many players on a single page
- Progressive loading: Place most important tracks at the top with eager loading
Technical Details
URL Encoding
The component automatically encodes thetrackUrl using encodeURIComponent() to ensure safe URL parameter handling.
SoundCloud Widget API
The player uses the official SoundCloud widget endpoint:Accessibility
The iframe includes a descriptivetitle attribute for screen readers: