react-native-bundled-assets
v0.1.0
Published
Read bundled assets (text/JSON) from iOS and Android with a unified API.
Maintainers
Readme
react-native-bundled-assets
Read bundled assets (text/JSON) in React Native with a unified API for iOS and Android.
Features
- Read assets from native bundle (not JS bundle)
- Unified API for iOS and Android
- Lightweight TurboModule (no heavy FS libraries)
- Simple and focused (text + JSON only)
Installation
npm install react-native-bundled-assetsThen install iOS pods:
cd ios && pod installUsage
import { readJSON, readText } from 'react-native-bundled-assets';
const data = await readJSON('test.json');
console.log(data);
const text = await readText('test.txt');
console.log(text);How to add assets
Add assets using react-native-asset:
- Configure assets in
react-native.config.js:
module.exports = {
assets: ['./src/assets'],
};- Place your files:
src/assets/test.json- Link assets:
npx react-native-assetPath behavior
Use the same path on both platforms:
readJSON('test.json');Internally:
- iOS → reads from app bundle
- Android → reads from
assets/custom/
Important
Bundled assets are not secure.
They are not included in the JS bundle, but can still be extracted from the app.
API
readText(path: string): Promise<string>
Read a text file from bundled assets.
readJSON<T>(path: string): Promise<T>
Read and parse a JSON file.
Contributing
License
MIT
Made with create-react-native-library
