Skip to main content
AppRegistry is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry.registerComponent, then the native system can load the bundle for the app and run it when ready by invoking AppRegistry.runApplication.

Methods

registerComponent()

Registers an app’s root component. This is the main method you’ll use in your app’s entry file. Parameters:
  • appKey: String name for the application
  • componentProvider: Function that returns a React component
  • section: Optional boolean to register as a section
Returns:
  • The appKey that was registered
Example:

runApplication()

Loads the JavaScript bundle and runs the app. Usually called from native code. Parameters:
  • appKey: The string name of the app to run
  • appParameters: Object containing:
    • initialProps: Props to pass to the root component
    • rootTag: The native root view tag
    • fabric: Whether Fabric renderer is enabled
  • displayMode: Optional display mode configuration
Example:

unmountApplicationComponentAtRootTag()

Stops an application when a view should be destroyed. Should be used as a pair with runApplication. Parameters:
  • rootTag: The root tag that was passed to runApplication
Example:

registerHeadlessTask()

Register a headless task - code that runs without a UI (e.g., handling push notifications in the background). Parameters:
  • taskKey: Unique string identifier for the task
  • taskProvider: Function that returns an async task function
Example:

registerCancellableHeadlessTask()

Register a cancellable headless task that can be stopped mid-execution. Parameters:
  • taskKey: Unique string identifier for the task
  • taskProvider: Function that returns an async task function
  • taskCancelProvider: Function that returns a cancellation function
Example:

startHeadlessTask()

Starts a headless task. Only called from native code. Parameters:
  • taskId: Numeric ID for this task instance
  • taskKey: The registered task key
  • data: Data to pass to the task

cancelHeadlessTask()

Cancels a running headless task. Only called from native code. Parameters:
  • taskId: The task instance ID
  • taskKey: The registered task key

setSurfaceProps()

Updates initial props for a surface that’s already rendered. Parameters:
  • appKey: The registered app key
  • appParameters: New parameters/props
  • displayMode: Optional display mode

getAppKeys()

Returns an array of all registered app keys. Returns:
  • Array of registered application keys

getRunnable()

Gets the runnable function for a registered app. Parameters:
  • appKey: The app key to look up
Returns:
  • The runnable function or undefined if not found

Typical Usage

In your app’s entry file (usually index.js):