Search code examples
reactjsionic4splash-screencapacitor

Hide Splash Screen in Ionic Capacitor React


How can we disable the splash screen on an Ionic App? I am using Ionic 4, Capacitor and React. I have tried to add this on capacitor.config.json

{
  "plugins": {
    "SplashScreen": {
      "launchShowDuration": 0
    }
  }
}

The above code is not working at all.


Solution

  • You can hide the splash screen using the SplashScreen plugin :

    import { Plugins } from '@capacitor/core';
    const { SplashScreen } = Plugins;
    
    function useSplashHide(){
        useEffect(() => {
            SplashScreen.hide();
        }, []);
    } 
    

    You can use it like any hooks :

    function MyComponent(props){
      useSplashHide()
    
      return <>....</>
    }
    

    Documentation is here