Skip to content

Spotify ​

Spotify is a music, podcast, and audiobook streaming service. Protocol Launcher allows you to generate official Spotify links for opening Spotify content.

Usage ​

There are two ways to use this library:

  • On-Demand import from subpaths enables tree-shaking and keeps bundles small.
  • Full Import from the root package is convenient but includes all app modules.

Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.

Select Installation Method

On-Demand
Recommended. Optimized for production.
Full Import
Convenient. Good for quick scripts.

Spotify's official content linking docs cover Spotify URIs (spotify:...), https://spotify.link/content_linking links, and fallback web links from external_urls.spotify. These helpers mirror those documented forms and do not include undocumented playback or search commands.

Open URI ​

Open an official Spotify URI. Spotify documents these as values returned by Spotify APIs, for example spotify:album:4oktVvRuO1In9B7Hz0xm0a.

On-Demand
ts
import { openUri } from 'protocol-launcher/spotify'

const url = openUri({
  uri: 'spotify:album:4oktVvRuO1In9B7Hz0xm0a',
})

Generate Spotify's iOS content linking URL with the official ~campaign and $canonical_url parameters.

On-Demand
ts
import { openIosContentLink } from 'protocol-launcher/spotify'

const url = openIosContentLink({
  campaign: 'com.app',
  canonicalUrl: 'https://open.spotify.com/album/0sNOF9WDwhWunNAHPD3Baj',
})

Generate Spotify's Android content linking URL with the official ~campaign, $deeplink_path, and $fallback_url parameters.

On-Demand
ts
import { openAndroidContentLink } from 'protocol-launcher/spotify'

const url = openAndroidContentLink({
  campaign: 'com.app',
  deeplinkPath: 'https://open.spotify.com/album/0sNOF9WDwhWunNAHPD3Baj',
  fallbackUrl: 'https://open.spotify.com/album/0sNOF9WDwhWunNAHPD3Baj',
})

Open a Spotify fallback web link from external_urls.spotify. When utmCampaign is provided, the helper serializes Spotify's official utm_campaign attribution parameter and keeps existing query parameters.

On-Demand
ts
import { openWebLink } from 'protocol-launcher/spotify'

const url = openWebLink({
  url: 'https://open.spotify.com/track/55fmthmn3rgnk9Wyx7G5dU',
  utmCampaign: 'com.app',
})

Official Documentation ​