@sekizlipenguen/react-native-splash-helper
v0.0.3
Published
A lightweight React Native library to automatically configure splash screens for both Android and iOS platforms. Simplifies the splash screen setup process for React Native developers.
Maintainers
Readme
@sekizlipenguen/react-native-splash-helper
A lightweight CLI that generates native splash screen assets for bare React Native apps (Android + iOS) from react-native.config.js.
This package is a generator, not a runtime splash controller. After the native splash dismisses, hide/retain logic is up to your app (e.g.
react-native-bootsplashor the AndroidX SplashScreen API).
Example
A React Native 0.86.2 playground lives in example/. See example/README.md for setup and iOS run instructions.
Features
- Config-driven splash generation for Android and iOS
- Theme discovery from
AndroidManifest.xml(application + LAUNCHER activity) resizeMode:cover|contain|fill- Optional dark mode colors / images
- Android 12+
values-v31SplashScreen attributes (with legacywindowBackgroundfallback) - Auto-wire AndroidX SplashScreen (
wireNative) + full-bleed cover overlay - Optional density generation via
sharp --android/--ios/--dry-runflags
Installation
yarn add @sekizlipenguen/react-native-splash-helper --dev
# or
npm install @sekizlipenguen/react-native-splash-helper --save-devOptional (Android density buckets):
yarn add sharp --devConfiguration
Add a section to react-native.config.js:
module.exports = {
'@sekizlipenguen/react-native-splash-helper': {
android: {
splashImage: './assets/splash.png',
backgroundColor: '#FFFFFF',
darkBackgroundColor: '#000000', // optional
darkSplashImage: './assets/splash-dark.png', // optional
resizeMode: 'cover', // cover | contain | fill
android12: true, // default true — writes values-v31 styles
wireNative: true, // default true — patches build.gradle + MainActivity
generateDensities: false, // set true + install sharp for mdpi…xxxhdpi
},
ios: {
splashImage: './assets/splash.png',
backgroundColor: '#FFFFFF',
darkSplashImage: './assets/splash-dark.png', // optional (imageset appearances)
resizeMode: 'cover',
},
},
};Options
| Option | Platform | Default | Description |
|--------|----------|---------|-------------|
| splashImage | Both | — | Path to splash image (png / jpg / webp). Required. |
| backgroundColor | Both | #FFFFFF | Hex background (#FFF, #FFFFFF, or #RRGGBBAA). |
| darkBackgroundColor | Android | — | Night colors.xml splash background. |
| darkSplashImage | Both | — | Dark image (drawable-night / iOS imageset appearance). |
| resizeMode | Both | cover | cover (aspect-fill), contain (letterbox), or fill (stretch). On Android, cover is baked with sharp into a 1080×2400 image so it does not squash. |
| android12 | Android | true | Write Android 12+ SplashScreen style attrs under values-v31. |
| wireNative | Android | true | Auto-add core-splashscreen and wire installSplashScreen() in MainActivity (cover overlay for cover/fill). |
| generateDensities | Android | false | Generate density drawables with sharp. |
Usage
npx react-native-splash-helper
# or
npx @sekizlipenguen/react-native-splash-helper generate-splashFlags:
npx react-native-splash-helper --android
npx react-native-splash-helper --ios
npx react-native-splash-helper --dry-runReact Native CLI command (via package.json commands export):
npx react-native generate-splashWhat it writes
Android
- Updates detected themes in
styles.xmlwithandroid:windowBackground→@drawable/splash_background - Creates/updates
values/colors.xml(splash_background) - Writes
drawable/splash_background.xml+ copiessplash_image.* - Optional:
values-night/colors.xml,drawable-night/ - Optional:
values-v31/styles.xmlwithwindowSplashScreenBackground/windowSplashScreenAnimatedIcon - Optional:
drawable-mdpi…drawable-xxxhdpiwhengenerateDensities: trueandsharpis installed - With
wireNative(default):android/app/build.gradle+MainActivitySplashScreen wiring
Android 12+ / cover note: The system splash background may only be a solid color, and the animated icon is always a centered circle — a full-bleed image there looks squashed. With defaults (android12 + wireNative), generate-splash:
- Bakes the image with
sharpto 1080×2400 (fit: 'cover') - Writes
values-v31color + icon mask - Adds
androidx.core:core-splashscreentoandroid/app/build.gradle - Wires
MainActivitywithinstallSplashScreen()and a shortCENTER_CROPcover overlay
Set wireNative: false to skip Gradle/MainActivity patching. For logo-style splash use resizeMode: 'contain'.
iOS
- Overwrites
LaunchScreen.storyboardwith a full-bleed image + configured background color - Creates/updates
Images.xcassets/splash_image.imagesetwith a stable filename (no random cache-bust names) - Optional dark image via Xcode
appearances
The storyboard file is replaced on each run so results stay predictable.
Notes
- Run the generator from the React Native project root (where
react-native.config.jslives). - Missing/invalid config exits with code
1and a clear message. - This tool does not manage the in-JS splash after the native layer hands off to React Native.
License
MIT © Sekizli Penguen
