getDefaultReactHost

fun getDefaultReactHost(context: Context, packageList: List<ReactPackage>, jsMainModulePath: String = "index", jsBundleAssetPath: String = "index", jsBundleFilePath: String? = null, jsRuntimeFactory: JSRuntimeFactory? = null, useDevSupport: Boolean = ReactBuildConfig.DEBUG, cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList()): ReactHost

Util function to create a default ReactHost to be used in your application. This method is used by the New App template.

Parameters

context

the Android Context to use for creating the ReactHost

packageList

the list of ReactPackages to use for creating the ReactHost

jsMainModulePath

the path to your app's main module on Metro. Usually index or index.<platform>

jsBundleAssetPath

the path to the JS bundle relative to the assets directory. Will be composed in a asset://... URL

jsBundleFilePath

the path to the JS bundle on the filesystem. Will be composed in a file://... URL

jsRuntimeFactory

the JS engine to use for executing ReactHost, default to Hermes.

useDevSupport

whether to enable dev support, default to ReactBuildConfig.DEBUG.

cxxReactPackageProviders

a list of cxxreactpackage providers (to register c++ turbo modules)

TODO(T186951312): Should this be @UnstableReactNativeAPI?


fun getDefaultReactHost(context: Context, packageList: List<ReactPackage>, jsMainModulePath: String = "index", jsBundleAssetPath: String = "index", jsBundleFilePath: String? = null, jsRuntimeFactory: JSRuntimeFactory? = null, useDevSupport: Boolean = ReactBuildConfig.DEBUG, cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(), exceptionHandler: (Exception) -> Unit = { throw it }, bindingsInstaller: BindingsInstaller? = null): ReactHost

Util function to create a default ReactHost to be used in your application. This method is used by the New App template.

Parameters

context

the Android Context to use for creating the ReactHost

packageList

the list of ReactPackages to use for creating the ReactHost

jsMainModulePath

the path to your app's main module on Metro. Usually index or index.<platform>

jsBundleAssetPath

the path to the JS bundle relative to the assets directory. Will be composed in a asset://... URL

jsBundleFilePath

the path to the JS bundle on the filesystem. Will be composed in a file://... URL

jsRuntimeFactory

the JS engine to use for executing ReactHost, default to Hermes.

useDevSupport

whether to enable dev support, default to ReactBuildConfig.DEBUG.

cxxReactPackageProviders

a list of cxxreactpackage providers (to register c++ turbo modules)

exceptionHandler

Callback that can be used by React Native host applications to react to exceptions thrown by the internals of React Native.

bindingsInstaller

that can be used for installing bindings.

TODO(T186951312): Should this be @UnstableReactNativeAPI?


fun getDefaultReactHost(context: Context, reactNativeHost: ReactNativeHost, jsRuntimeFactory: JSRuntimeFactory? = null): ReactHost

Util function to create a default ReactHost to be used in your application. This method is used by the New App template.

This method takes in input a ReactNativeHost (bridge-mode) and uses its configuration to create an equivalent ReactHost (bridgeless-mode).

Parameters

context

the Android Context to use for creating the ReactHost

reactNativeHost

the ReactNativeHost to use for creating the ReactHost

TODO(T186951312): Should this be @UnstableReactNativeAPI? It's not, to maintain consistency with above getDefaultReactHost.


fun getDefaultReactHost(context: Context, packageList: List<ReactPackage>, jsMainModulePath: String = "index", jsBundleAssetPath: String = "index", jsBundleFilePath: String? = null, isHermesEnabled: Boolean = true, useDevSupport: Boolean = ReactBuildConfig.DEBUG, cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(), exceptionHandler: (Exception) -> Unit = { throw it }, bindingsInstaller: BindingsInstaller? = null): ReactHost

Deprecated

Use `getDefaultReactHost` with `jsRuntimeFactory` instead

Replace with


      fun getDefaultReactHost(
        context: Context,
        packageList: List<ReactPackage>,
        jsMainModulePath: String,
        jsBundleAssetPath: String,
        jsBundleFilePath: String?,
        jsRuntimeFactory: JSRuntimeFactory?,
        useDevSupport: Boolean,
        cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>,
        exceptionHandler: (Exception) -> Unit,
        bindingsInstaller: BindingsInstaller?,
      ): ReactHost
    

Util function to create a default ReactHost to be used in your application. This method is used by the New App template.

Parameters

context

the Android Context to use for creating the ReactHost

packageList

the list of ReactPackages to use for creating the ReactHost

jsMainModulePath

the path to your app's main module on Metro. Usually index or index.<platform>

jsBundleAssetPath

the path to the JS bundle relative to the assets directory. Will be composed in a asset://... URL

jsBundleFilePath

the path to the JS bundle on the filesystem. Will be composed in a file://... URL

isHermesEnabled

whether to use Hermes as the JS engine, default to true.

useDevSupport

whether to enable dev support, default to ReactBuildConfig.DEBUG.

cxxReactPackageProviders

a list of cxxreactpackage providers (to register c++ turbo modules)

exceptionHandler

Callback that can be used by React Native host applications to react to exceptions thrown by the internals of React Native.

bindingsInstaller

that can be used for installing bindings.


fun getDefaultReactHost(context: Context, packageList: List<ReactPackage>, jsMainModulePath: String = "index", jsBundleAssetPath: String = "index", jsBundleFilePath: String? = null, isHermesEnabled: Boolean = true, useDevSupport: Boolean = ReactBuildConfig.DEBUG, cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList()): ReactHost

Deprecated

Use `getDefaultReactHost` with `jsRuntimeFactory` instead

Replace with


      fun getDefaultReactHost(
        context: Context,
        packageList: List<ReactPackage>,
        jsMainModulePath: String,
        jsBundleAssetPath: String,
        jsBundleFilePath: String?,
        jsRuntimeFactory: JSRuntimeFactory?,
        useDevSupport: Boolean,
        cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage>,
      ): ReactHost
    

Util function to create a default ReactHost to be used in your application. This method is used by the New App template.

Parameters

context

the Android Context to use for creating the ReactHost

packageList

the list of ReactPackages to use for creating the ReactHost

jsMainModulePath

the path to your app's main module on Metro. Usually index or index.<platform>

jsBundleAssetPath

the path to the JS bundle relative to the assets directory. Will be composed in a asset://... URL

jsBundleFilePath

the path to the JS bundle on the filesystem. Will be composed in a file://... URL

isHermesEnabled

whether to use Hermes as the JS engine, default to true.

useDevSupport

whether to enable dev support, default to ReactBuildConfig.DEBUG.

cxxReactPackageProviders

a list of cxxreactpackage providers (to register c++ turbo modules)