--- id: appregistry title: AppRegistry layout: docs category: APIs permalink: docs/appregistry.html next: appstate previous: animated ---
`AppRegistry` is the JavaScript 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 then actually run the app when it's ready by invoking `AppRegistry.runApplication()`. To "stop" an application when a view should be destroyed, call `AppRegistry.unmountApplicationComponentAtRootTag()` with the tag that was passed into `runApplication()`. These should always be used as a pair. `AppRegistry` should be `require`d early in the `require` sequence to make sure the JavaScript execution environment is set up before other modules are `require`d. ### Methods - [`registerComponent`](docs/appregistry.html#registercomponent) - [`runApplication`](docs/appregistry.html#runapplication) - [`unmountApplicationComponentAtRootTag`](docs/appregistry.html#unmountapplicationcomponentatroottag) - [`registerHeadlessTask`](docs/appregistry.html#registerheadlesstask) - [`startHeadlessTask`](docs/appregistry.html#startheadlesstask) - [`setWrapperComponentProvider`](docs/appregistry.html#setwrappercomponentprovider) - [`registerConfig`](docs/appregistry.html#registerconfig) - [`registerRunnable`](docs/appregistry.html#registerrunnable) - [`registerSection`](docs/appregistry.html#registersection) - [`getAppKeys`](docs/appregistry.html#getappkeys) - [`getSectionKeys`](docs/appregistry.html#getsectionkeys) - [`getSections`](docs/appregistry.html#getsections) - [`getRunnable`](docs/appregistry.html#getrunnable) - [`getRegistry`](docs/appregistry.html#getregistry) - [`setComponentProviderInstrumentationHook`](docs/appregistry.html#setcomponentproviderinstrumentationhook) --- # Reference ## Methods ### `registerComponent()` ```javascript AppRegistry.registerComponent(appKey, componentProvider, [section]) ``` Registers an app's root component. **Parameters:** | Name | Type | Required | Description | | - | - | - | - | | appKey | string | Yes | Application key. | | componentProvider | function | Yes | A function that returns a React component or element. | | section | boolean | No | Is this a section? | --- ### `runApplication()` ```javascript AppRegistry.runApplication(appKey, appParameters) ``` Loads the JavaScript bundle and runs the app. **Parameters:** | Name | Type | Required | Description | | - | - | - | - | | appKey | string | Yes | Application key. | | appParameters | any | Yes | Params. | --- ### `unmountApplicationComponentAtRootTag()` ```javascript AppRegistry.unmountApplicationComponentAtRootTag(rootTag) ``` Stops an application when a view should be destroyed. The `rootTag` should match the tag that was passed into `runApplication()`. These should always be used as a pair. **Parameters:** | Name | Type | Required | Description | | - | - | - | - | | rootTag | number | Yes | React tag. | --- ### `registerHeadlessTask()` ```javascript AppRegistry.registerHeadlessTask(taskKey, task) ``` Register a headless task. A headless task is a bit of code that runs without a UI. **Parameters:** | Name | Type | Required | Description | | - | - | - | - | | taskKey | string | No | The key associated with this task. | | task | function | No | A promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context. | --- ### `startHeadlessTask()` ```javascript AppRegistry.startHeadlessTask(taskId, taskKey, data) ``` Only called from native code. Starts a headless task. **Parameters:** | Name | Type | Required | Description | | - | - | - | - | | taskId | number | No | The native id for this task instance to keep track of its execution. | | taskKey | string | No | The key for the task to start. | | data | any | No | The data to pass to the task. | --- ### `setWrapperComponentProvider()` ```javascript AppRegistry.setWrapperComponentProvider(provider) ``` --- ### `registerConfig()` ```javascript AppRegistry.registerConfig(config) ``` --- ### `registerRunnable()` ```javascript AppRegistry.registerRunnable(appKey, run) ``` --- ### `registerSection()` ```javascript AppRegistry.registerSection(appKey, component) ``` --- ### `getAppKeys()` ```javascript AppRegistry.getAppKeys() ``` --- ### `getSectionKeys()` ```javascript AppRegistry.getSectionKeys() ``` --- ### `getSections()` ```javascript AppRegistry.getSections() ``` --- ### `getRunnable()` ```javascript AppRegistry.getRunnable(appKey) ``` --- ### `getRegistry()` ```javascript AppRegistry.getRegistry() ``` --- ### `setComponentProviderInstrumentationHook()` ```javascript AppRegistry.setComponentProviderInstrumentationHook(hook) ```