Search code examples
javascriptandroidreact-nativesplash-screenlaunch-screen

How do you make a launch/splash screen for android in React-Native?


I've been searching for a while now and I have not found anything on how to add a launch/splash screen to my android app with react-native.

I've seen many examples of how to do this for iOS, but I also need it to work with android. I'd love something that can work cross-platform but if that is not possible with current react-native, I can implement it for both. I've also seen a way to do it with java, but I would really prefer not tainting my app with java code, trying to keep as much as I can written in react.

Would anyone know how this could be done?


Solution

  • Splash screens are a built-in feature of iOS apps - you can't not have a splash screen on iOS.

    However, generally Android apps don't have them. The apps that do tend to simulate it by having an image that displays for a couple of seconds when they first start.

    That's pretty easy to do in react-native (use a setTimeout with setState({showSplashScreen:false}) or similar. Wrap it in a check for Android, and you're there.

    EDIT: As the OP points out in the comments, this causes a 'white flash' while the app is loading, so it looks like for now the best solution is to use a plugin or custom Java code.