Linking and unlinking of assets in your react-native app, works for fonts and sounds
npm install react-native-asset

- react-native link only supports font files, this tool supports all assets.
- Unlinking is automatic when you delete an asset, with react-native link, you
need to unlink the files manually.
- Proper link (and unlink) for mp3 (to use with
react-native-sound)
and ttf files.
- Install (globally or locally and later run with npx)
``bash`
npm install -g react-native-asset
react-native.config.js
- Add assets to your as you would withreact-native link
`
js`
...
assets: [
"./src/font",
"./src/mp3",
];
react-native.config.js
- Add platform-specific assets to your like so:
`js`
...
assets: [
"./src/mp3",
],
iosAssets: [
"./src/font/ios",
],
androidAssets: [
"./src/font/android",
],
- Run the command and linking + unlinking is automatic!
`bash`
react-native-asset
`
Can also run with Deno without installing
`
deno run jsr:@unimonkiez/react-native-asset
With react-native link you have to unlink the files manually, which is hardlink-assets-manifest.json
work.\
Instead this library writes to the root of androidios
and folders to keep track of the files which it added, for later removingassets
it for you if missing from your !
- -p, --path - path to project, defaults to cwd.-a, --assets
- - assets paths, for examplereact-native-asset -a ./src/font ./src/mp3
.-ios-a, --ios-assets
- - ios assets paths, will disable android linking-android-a, --android-assets
- - android assets paths, will disable ios-n-u, --no-unlink` - Not to unlink assets which not longer exists, not
linking.
-
recommended.
- to use react-native 0.59 and below, use version 1.1.4