Skip to content

ReactHook

Spicetify.ReactHook holds React hooks that the wrapper finds in Spotify’s bundle. Call them only inside React components rendered by the client’s React.

namespace ReactHook {
function DragHandler(
uris?: string[],
label?: string,
contextUri?: string,
sectionIndex?: number,
dropOriginUri?: string,
): (event: React.DragEvent, uris?: string[], label?: string, contextUri?: string, sectionIndex?: number) => void;
function useExtractedColor(uri: string, fallbackColor?: string, variant?: 'colorRaw' | 'colorLight' | 'colorDark'): string;
}

v3 has no usePanelState. See Panel for the v3 panel controller.

DragHandler

DragHandler returns an onDragStart handler that lets the user drag items onto Spotify’s playlists, folders, sidebar and queue.

ParameterTypeDescription
urisstring[] | undefinedThe URIs to drag.
labelstring | undefinedThe text shown while dragging.
contextUristring | undefinedThe URI of the context the drag starts from, such as a playlist.
sectionIndexnumber | undefinedThe index of the section the drag starts from.
dropOriginUristring | undefinedThe only target that accepts the drop. Leave it empty to allow any target.
function DraggableTrack() {
const onDragStart = Spicetify.ReactHook.DragHandler(['spotify:track:5FVd6KXrgO9B3JPmC8OPst'], 'Do I Wanna Know?');
return (
<div draggable onDragStart={onDragStart}>
Do I Wanna Know?
</div>
);
}

useExtractedColor

useExtractedColor returns a hex color extracted from an image, through Spotify’s GraphQL API. It uses React Query, so the component must render inside a QueryClientProvider.

ParameterTypeDescription
uristringThe URI or URL of a Spotify image.
fallbackColorstring | undefinedThe color to return when the image has none. Defaults to #535353.
variant'colorRaw' | 'colorLight' | 'colorDark' | undefinedThe variant to return. Defaults to colorRaw.
const { QueryClient, QueryClientProvider } = Spicetify.ReactQuery;
const queryClient = new QueryClient();
function ArtworkBackground({ imageUri }: { imageUri: string }) {
const color = Spicetify.ReactHook.useExtractedColor(imageUri);
return <div style={{ backgroundColor: color }} />;
}
function App() {
const imageUri = Spicetify.Player.data?.item.metadata.image_xlarge_url ?? '';
return (
<QueryClientProvider client={queryClient}>
<ArtworkBackground imageUri={imageUri} />
</QueryClientProvider>
);
}