Guides
Plan-enterprise-icon
Expo Application Services
API Reference

SplashScreen

The SplashScreen module from the expo-splash-screen library is used to tell the splash screen to remain visible until it has been explicitly told to hide. This is useful to do tasks that will happen behind the scenes such as making API calls, pre-loading fonts, animating the splash screen and so on.
Also, see the guide on creating a splash screen image, or quickly generate an icon and splash screen using your browser.

Platform Compatibility

Android DeviceAndroid EmulatoriOS DeviceiOS SimulatorWeb
Status-success-iconStatus-success-iconStatus-success-iconStatus-success-iconStatus-failed-icon

Installation

Terminal
→ npx expo install expo-splash-screen

If you're installing this in a bare React Native app, you should also follow these additional installation instructions.

Usage

This example shows how to keep the splash screen visible while loading app resources and then hide the splash screen when the app has rendered some initial content.
import React, { useCallback, useEffect, useState } from 'react';
import { Text, View } from 'react-native';
import Entypo from '@expo/vector-icons/Entypo';
import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';

// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();

export default function App() {
  const [appIsReady, setAppIsReady] = useState(false);

  useEffect(() => {
    async function prepare() {
      try {
        // Pre-load fonts, make any API calls you need to do here
        await Font.loadAsync(Entypo.font);
        // Artificially delay for two seconds to simulate a slow loading
        // experience. Please remove this if you copy and paste the code!
        await new Promise(resolve => setTimeout(resolve, 2000));
      } catch (e) {
        console.warn(e);
      } finally {
        // Tell the application to render
        setAppIsReady(true);
      }
    }

    prepare();
  }, []);

  const onLayoutRootView = useCallback(async () => {
    if (appIsReady) {
      // This tells the splash screen to hide immediately! If we call this after
      // `setAppIsReady`, then we may see a blank screen while the app is
      // loading its initial state and rendering its first pixels. So instead,
      // we hide the splash screen once we know the root view has already
      // performed layout.
      await SplashScreen.hideAsync();
    }
  }, [appIsReady]);

  if (!appIsReady) {
    return null;
  }

  return (
    <View
      style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}
      onLayout={onLayoutRootView}>
      <Text>SplashScreen Demo! 👋</Text>
      <Entypo name="rocket" size={30} />
    </View>
  );
}

Animating the splash screen

See the with-splash-screen example on how to apply any arbitrary animations to your splash screen, such as a fade out. You can initialize a new project from this example by running npx create-react-native-app -t with-splash-screen.

API

import * as SplashScreen from 'expo-splash-screen';

Methods

SplashScreen.hideAsync()

Hides the native splash screen immediately. Be careful to ensure that your app has content ready to display when you hide the splash screen, or you may see a blank screen briefly. See the "Usage" section for an example.

Returns

  • Undo-iconPromise<boolean>

SplashScreen.preventAutoHideAsync()

Makes the native splash screen (configured in app.json) remain visible until hideAsync is called.

Info-icon

Important note: It is recommended to call this in global scope without awaiting, rather than inside React components or hooks, because otherwise this might be called too late, when the splash screen is already hidden.

Example

import * as SplashScreen from 'expo-splash-screen';

SplashScreen.preventAutoHideAsync();

export default function App() {
 // ...
}
  • Message-iconAsk a question on the forums about SplashScreen
  • Github-iconView open bug reports for SplashScreen
  • Code-iconView source code for SplashScreen
  • Build-iconView package in npm Registry
  • Edit-iconEdit this page

Was this doc helpful?