Expo DevClient iconExpo DevClient

允许创建开发版本并包含有用开发工具的库。

Android
iOS

expo-dev-client 在你的调试版本中添加了各种有用的开发工具:

¥expo-dev-client adds various useful development tools to your debug builds:

Expo 文档引用了包含 expo-dev-client开发构建 的调试版本。

¥Expo documentation refers to debug builds that include expo-dev-client as development builds.

安装

¥Installation

Terminal
npx expo install expo-dev-client

如果你要在 现有的 React Native 应用 中安装它,请先在项目中安装 expo。然后,按照 在现有的 React Native 中安装 expo-dev-client 项目 中的说明进行操作。

¥If you are installing this in an existing React Native app, start by installing expo in your project. Then, follow the instructions from Install expo-dev-client in an existing React Native project.

应用配置中的配置

¥Configuration in app config

如果你在项目中使用配置插件(EAS 构建npx expo run:[android|ios]),则可以使用其内置的 配置插件 配置开发客户端启动器。该插件允许你配置无法在运行时设置的各种属性,并且需要构建新的应用二进制文件才能生效。

¥You can configure development client launcher using its built-in config plugin if you use config plugins in your project (EAS Build or npx expo run:[android|ios]). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect.

Example app.json with config plugin

app.json
{
"expo": {
  "plugins": [
    [
      "expo-dev-client",
      {
        "launchMode": "most-recent"
      }
    ]
  ]
}
}

Configurable properties

NameDefaultDescription
launchMode"most-recent"

Determines whether to launch the most recently opened project or navigate to the launcher screen.

  • most-recent - Attempt to launch directly into a previously opened project and if unable to connect, fall back to the launcher screen.
  • launcher - Opens the launcher screen.
addGeneratedSchemetrue

By default, expo-dev-client will register a custom URL scheme to open a project. Set this property to false to disable this scheme.

API

import * as DevClient from 'expo-dev-client';

Methods

DevClient.closeMenu()

Android
iOS

A method that closes development client menu when called.

Returns:
void

DevClient.hideMenu()

Android
iOS

A method that hides development client menu when called.

Returns:
void

DevClient.isDevelopmentBuild()

Android
iOS

A method that returns a boolean to indicate if the current application is a development build.

Returns:
boolean

DevClient.openMenu()

Android
iOS

A method that opens development client menu when called.

Returns:
void

DevClient.registerDevMenuItems(items)

Android
iOS
ParameterType
itemsExpoDevMenuItem[]

A method that allows to specify custom entries in the development client menu.

Returns:
Promise<void>

Types

ExpoDevMenuItem

Android
iOS

An object representing the custom development client menu entry.

PropertyTypeDescription
callback() => void

Callback to fire, when user selects an item.

namestring

Name of the entry, will be used as label.

shouldCollapse(optional)boolean

A boolean specifying if the menu should close after the user interaction.

Default:false