Skip to content
← Public packages

@kentcdodds/spotify

Spotify playback, playlist, search, library, and device helpers.

src/exports/add-to-queue.ts

21 lines · 855 B · TypeScript
import { addToQueue } from '../lib/spotify-api.ts'
import type { AddToQueueParams } from '../lib/export-types.ts'

/**
 * Add a track or episode URI to the end of the Spotify queue.
 * Prefer `deviceName` when targeting a device; omit selectors for the active device.
 * All params accept an optional `account` ('personal' | 'family', default 'personal').
 * @returns Confirmation with ok, action 'queued', uri, and status.
 * @example
 * import addToQueue from 'kody:@kentcdodds/spotify/add-to-queue'
 * const result = await addToQueue({ uri: 'spotify:track:4cOdK2wGLETKBW3PvgPWqT' })
 * // => { ok: true, action: 'queued', uri: 'spotify:track:...', status: 204 }
 */
async function spotifyAddToQueue(params: AddToQueueParams = {}) {
	return await addToQueue({
		...params,
		uri: params.uri ?? params.spotifyUri,
	})
}

export default spotifyAddToQueue