TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published


IMPORTANT: This project is in early development


This project surged from our own needs, as there's no Spotify plugin available for NativeScript (or at least updated).

For now, the goal of this plugin is simple: Integrate Spotify into your app through the Spotify App Remote SDK, so you can control playback and get the user recommended content items.

Later (maybe), we can implement the Spotify Authentication SDK and Web API for more features, but that will depend on our available time and needs, so, feel free to help the project through issue submissions and pull requests.


Add the plugin to your NativeScript project with:

ns plugin add @nuxstep/nativescript-spotify


In your app project, head over to App_Resources/Android/src/main/res and open AndroidManifest.xml. Inside the <activity> tag with the name com.tns.NativeScriptActivity, add the property android:launchMode="singleTask", as follows:


Before the first <activity> tag is closed, add the following:

<!-- Custom URI schemes -->
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />

    android:host="spotify-login-callback" />

Here you will set the Redirect URI for the Spotify App Remote authentication (it reads as plugindemo://spotify-login-callback). Change the android:scheme to something related to your app (like myapp) and host you can keep it as spotify-login-callback. Write down your Redirect URI, you will need it to set up the SpotifyAppRemote class.

Before the <application> tag closes, add the following:

<!-- Spotify Activity -->
  android:theme="@android:style/Theme.Translucent.NoTitleBar" />

For Android 11 or higher, you also need to specify which other applications your application can query (read about it here). To do that, simply add the following snippet one level below the <manifest> tag:

  <package android:name="com.spotify.music" />

You'll need an App Fingerprint too. Refer to https://developer.spotify.com/documentation/android/quick-start/#register-app-fingerprints on how to create one. Write it down because you will need it later.


In your app project, head over to App_Resources/iOS and open Info.plist. At the end of the file, before the last </dict> tag closes, add the following:


This allows the Spotify SDK to open the Spotify app through its URL scheme. After that, add the following:


Change com.nuxstep.nativescript.plugindemo to your app bundle name. Also, change plugindemo to your app URL scheme. Use the same URL scheme from Android for the sake of simplicity.

In your app entry point (usually app.ts), import isIOS and SpotifyAppRemote at the top of the file:

import { isIOS } from '@nativescript/core';
import { SpotifyAppRemote } from '@nuxstep/nativescript-spotify';

Then, implement a custom app delegate before your app starts, usually before Application.run() if you are using plain NativeScript.

 * Implement a custom AppDelegate on iOS so we can get the access token
 * returned from Spotify and store it on SpotifyAppRemote class
if (isIOS) {
	class AppDelegate extends UIResponder implements UIApplicationDelegate {
		public static ObjCProtocols = [UIApplicationDelegate];

		applicationOpenURLOptions(_application: UIApplication, url: NSURL, _options: any): boolean {
			return true;
	Application.ios.delegate = AppDelegate;

If you are not using TypeScript, refer to https://v7.docs.nativescript.org/core-concepts/application-lifecycle#ios-uiapplicationdelegate on how to implement the app delegate with JavaScript.

Spotify Developer

Head over to https://developer.spotify.com/dashboard and register a developer account.

In the dashboard, click on CREATE AN APP and provide a name and an description.

Inside your app dashboard, click on EDIT SETTINGS. Set the Redirect URI as you have defined before (e.g. myapp://spotify-login-callback) and click on ADD.

On section Bundle IDs, insert your app bundle name (e.g. com.example.myapp) and click on ADD. This one is for iOS.

On section Android Packages, insert your app package name (e.g. com.example.myapp) and insert the App Fingerprint you've created before. Click on ADD and then on SAVE to finish.

Write down your Client ID, you will need it to set up the SpotifyAppRemote class.


First, you need to pass the Client ID and Redirect URI to the SpotifyAppRemote class. You can do that in your app entry point before the custom app delegate:


In the page where you want to use SpotifyAppRemote, add to the top of the file:

import { isIOS } from '@nativescript/core';
import { SpotifyAppRemote } from '@nuxstep/nativescript-spotify';

Then, somewhere you want, connect to SpotifyAppRemote:

 * If platform is iOS, we need to open the app and start playback
 * before connecting to SpotifyAppRemote. This is an iOS-specific
 * limitation.
if (isIOS) {
	await SpotifyAppRemote.authorizeAndPlayURI();

await SpotifyAppRemote.connect();

You can pass any Spotify URI to authorizeAndPlayURI(). If you pass an empty string or no parameter at all, it'll try to play the user's last played song.

To understand how to use the plugin, refer to:

This README will be updated with the available methods at a later time.


Apache License Version 2.0

Package Sidebar


npm i @nuxstep/nativescript-spotify

Weekly Downloads






Unpacked Size

11.3 MB

Total Files


Last publish


  • andresilva.cc