npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nodefinity/react-native-music-library

v0.10.1

Published

Access local music files in React Native and get full metadata.

Readme

react-native-music-library

npm version License: MIT

中文

A powerful React Native library for accessing local music files and getting full metadata. Built with React Native's New Architecture (TurboModules) for optimal performance.

✨ Features

  • 🎵 Rich Metadata - Access local music with full metadata including lyrics, bitrate, sample rate, and more
  • 🚀 TurboModules - Built with React Native's New Architecture for maximum performance
  • 📄 Pagination - Cursor-based pagination for efficiently handling large music collections
  • 🔍 Flexible Sorting - Multiple sorting options for tracks, albums, and artists
  • 📁 Directory Filtering - Filter tracks by specific directories (Android)
  • 🔄 TypeScript - Full type definitions and type safety
  • 🎨 Album Artwork - Support for album artwork and cover images
  • 🤖 Android - Full native Android implementation
  • 🍎 iOS - Full native iOS implementation via MediaPlayer framework

🚀 Quick Start

Installation

npm install @nodefinity/react-native-music-library
# or
yarn add @nodefinity/react-native-music-library

Permissions

Android — add to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

iOS — add to Info.plist:

<key>NSAppleMusicUsageDescription</key>
<string>This app needs access to your music library.</string>

Basic Usage

import {
  getTracksAsync,
  getAlbumsAsync,
  getArtistsAsync,
} from '@nodefinity/react-native-music-library';

// Get first 20 tracks sorted by title
const result = await getTracksAsync({ sortBy: ['title', true] });
console.log(result.items); // Track[]
console.log(result.hasNextPage); // boolean
console.log(result.endCursor); // string | undefined

// Get next page
const nextPage = await getTracksAsync({
  sortBy: ['title', true],
  first: 20,
  after: result.endCursor,
});

📖 API

getTracksAsync(options?)

Returns a paginated list of tracks from the music library.

getTracksAsync(options?: TrackOptions): Promise<PaginatedResult<Track>>

TrackOptions

| Property | Type | Default | Description | | ----------- | -------------------------------------------------------- | ----------- | --------------------------------------- | | first | number | 20 | Max number of items to return | | after | string | — | Cursor from previous page's endCursor | | sortBy | TrackSortByKey \| [TrackSortByKey, boolean] \| (...)[] | 'default' | Sort key, or tuple [key, ascending] | | directory | string | — | Filter by directory path (Android only) |

TrackSortByKey: 'default' \| 'title' \| 'artist' \| 'album' \| 'duration' \| 'createdAt' \| 'modifiedAt' \| 'fileSize'


getTrackMetadataAsync(trackId)

Returns detailed audio metadata for a single track.

getTrackMetadataAsync(trackId: string): Promise<TrackMetadata>

getTracksByAlbumAsync(albumId)

Returns all tracks in an album (no pagination).

getTracksByAlbumAsync(albumId: string): Promise<Track[]>

getTracksByArtistAsync(artistId, options?)

Returns a paginated list of tracks by an artist.

getTracksByArtistAsync(artistId: string, options?: TrackOptions): Promise<PaginatedResult<Track>>

getAlbumsAsync(options?)

Returns a paginated list of albums.

getAlbumsAsync(options?: AlbumOptions): Promise<PaginatedResult<Album>>

AlbumOptions

| Property | Type | Default | Description | | -------- | -------------------------------------------------------- | ----------- | --------------------------------------- | | first | number | 20 | Max number of items to return | | after | string | — | Cursor from previous page's endCursor | | sortBy | AlbumSortByKey \| [AlbumSortByKey, boolean] \| (...)[] | 'default' | Sort key, or tuple [key, ascending] |

AlbumSortByKey: 'default' \| 'title' \| 'artist' \| 'trackCount' \| 'year'


getAlbumsByArtistAsync(artistId)

Returns all albums by an artist (no pagination).

getAlbumsByArtistAsync(artistId: string): Promise<Album[]>

getArtistsAsync(options?)

Returns a paginated list of artists.

getArtistsAsync(options?: ArtistOptions): Promise<PaginatedResult<Artist>>

ArtistOptions

| Property | Type | Default | Description | | -------- | ---------------------------------------------------------- | ----------- | --------------------------------------- | | first | number | 20 | Max number of items to return | | after | string | — | Cursor from previous page's endCursor | | sortBy | ArtistSortByKey \| [ArtistSortByKey, boolean] \| (...)[] | 'default' | Sort key, or tuple [key, ascending] |

ArtistSortByKey: 'default' \| 'title' \| 'trackCount' \| 'albumCount'


📦 Types

Track

| Field | Type | Description | | ------------ | --------- | ----------------------------------- | | id | string | Unique identifier | | title | string | Track title | | artist | string | Artist name | | artwork | string? | Artwork file URI (may be undefined) | | album | string | Album name | | duration | number | Duration in seconds | | url | string | File URI | | createdAt | number | Unix timestamp (seconds) | | modifiedAt | number | Unix timestamp (seconds) | | fileSize | number | File size in bytes |

TrackMetadata

| Field | Type | Description | | ------------- | -------- | ------------------------------------ | | id | string | Track ID | | duration | number | Duration in seconds | | bitrate | number | Bitrate in kbps | | sampleRate | number | Sample rate in Hz | | channels | string | Number of audio channels | | format | string | Audio format (e.g. "AAC", "MP3") | | title | string | Title tag | | artist | string | Artist tag | | album | string | Album tag | | year | number | Release year | | genre | string | Genre tag | | track | number | Track number | | disc | number | Disc number | | composer | string | Composer tag | | lyricist | string | Lyricist tag | | lyrics | string | Embedded lyrics | | albumArtist | string | Album artist tag | | comment | string | Comment tag |

Album

| Field | Type | Description | | ------------ | --------- | ------------------------------ | | id | string | Unique identifier | | title | string | Album name | | artist | string | Primary artist | | artwork | string? | Artwork URI (may be undefined) | | trackCount | number | Number of tracks | | year | number? | Release year |

Artist

| Field | Type | Description | | ------------ | -------- | ---------------------- | | id | string | Unique identifier | | title | string | Artist name | | albumCount | number | Number of albums | | trackCount | number | Total number of tracks |

PaginatedResult<T>

| Field | Type | Description | | ------------- | --------- | ----------------------------------------- | | items | T[] | Array of results | | hasNextPage | boolean | Whether more items are available | | endCursor | string? | Pass to after to fetch next page | | totalCount | number? | Total count (may be expensive to compute) |


🔄 Pagination Example

async function fetchAllTracks() {
  const allTracks = [];
  let cursor: string | undefined;

  do {
    const result = await getTracksAsync({ first: 50, after: cursor });
    allTracks.push(...result.items);
    cursor = result.hasNextPage ? result.endCursor : undefined;
  } while (cursor);

  return allTracks;
}

🤝 Contributing

See CONTRIBUTING.md for details.

📄 License

MIT License - see LICENSE for details.