npm install expo-modules-core

The core of Expo Modules architecture

About expo-modules-core

Expo-modules-core is an essential component of the Expo Modules architecture, designed to streamline the development process for building cross-platform applications using React Native. This npm package serves as the foundation for all other Expo modules, providing unified APIs and services that enhance the capabilities of React Native. The core module simplifies the integration of native functionality into applications, enabling developers to access device hardware and operating system features with minimal setup. By using expo-modules-core, developers benefit from increased efficiency and reduced complexity, making it easier to maintain and scale their applications across different platforms.

To incorporate expo-modules-core into your React Native project, developers can easily run the command `npm install expo-modules-core`. This installation adds a robust layer to the app development environment, allowing for seamless interaction with both hardware and software features of a device. The package ensures that developers can leverage Expo's ecosystem, which includes a wide range of APIs and components that are crucial for modern mobile applications. With npm install expo-modules-core, developers unlock the potential to significantly boost application performance and user experience by utilizing advanced features such as camera APIs, sensors, and much more.

Expo-modules-core not only acts as a bridge to device capabilities but also ensures that applications built with it are future-proof and compatible with upcoming versions of mobile platforms. This npm package facilitates the development of rich, interactive, and responsive applications that can run smoothly on both Android and iOS devices. The module's architecture promotes modular and clean code practices, which are key to building sustainable and robust applications. As a result, developers who adopt expo-modules-core can expect a more streamlined development cycle and a shorter time to market for their applications.

More from expo

expo npm packages

Find the best node modules for your project.

Search npm

expo-file-system

Provides access to the local file system on the device...

Read more
,

expo-modules-core

The core of Expo Modules...

Read more
,

expo-dev-menu

Expo/React Native module with the developer menu...

Read more
,

expo-dev-launcher

Pre-release version of the Expo development launcher package for testing...

Read more
,

expo-image

A cross-platform, performant image component for React Native and Expo with Web...

Read more
,

expo-clipboard

ExpoClipboard standalone...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

eslint, jsc-android, node-gyp, prettier, yarn-deduplicate

Documentation

A README file for the expo-modules-core code repository. View Code

expo-modules-core

The core of Expo Modules architecture.

Installation in managed Expo projects

For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.

Installation in bare React Native projects

For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.

Add the package to your npm dependencies

npm install expo-modules-core

Configure for iOS

Run npx pod-install after installing the npm package.

Configure for Android

No additional set up necessary.

Importing native dependencies - autolinking

Many React Native libraries come with platform-specific (native) code. This native code has to be linked into the project and, in some cases, configured further. These actions require some modifications to the native project files. One of the steps that has to be done with the native configuration is to enable the autolinking mechanism that takes care of including any supported module's native code into the project. The following configuration is required:

iOS

Caution! After you have made the following changes you will need to run pod install again.

# Podfile

require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('expo-modules-core/package.json')"`), "cocoapods.rb")
require File.join(File.dirname(`node --print "require.resolve('expo-modules-core/package.json')"`), "scripts/autolinking")

#  ...

target "TargetName" do
  use_unimodules!
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  # ...
end

Android

// app/build.gradle

apply from: new File(["node", "--print", "require.resolve('expo-modules-core/package.json')"].execute(null, rootDir).text.trim(), "../gradle.groovy")
apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
apply from: new File(["node", "--print", "require.resolve('expo-updates/package.json')"].execute(null, rootDir).text.trim(), "../scripts/create-manifest-android.gradle")

// ...

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
// settings.gradle

apply from: new File(["node", "--print", "require.resolve('expo-modules-core/package.json')"].execute(null, rootDir).text.trim(), "../gradle.groovy");
includeUnimodulesProjects()

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

Explanation

The scripts that are referenced in Gradle and Cocoapods are usually found the related package inside the project's node_modules directory. In the case of monorepos (such as Yarn workspaces) the project directory may not contain node_modules at all; instead, the modules are likely to be located at the root of the repository. In order to ensure that both cases are supported, we take advantage of the Node dependency resolution strategy. We invoke a subprocess that spawns the simple JavaScript snippet that tries to locate the desired npm package containing the script we need.

The Node process that is spawned runs require.resolve to obtain the path to a module's package.json(if you look for the module location using solely module name, you'll be given the path to the file pointed by the main attribute from the package.json and we need to know the location of the module's root directory). We then assemble the path to the desired script and execute it.

You can read more about the scripts and libraries used in the examples above in their official READMEs.

Contributing

Contributions are very welcome! Please refer to guidelines described in the contributing guide.