首页指南参考教程
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 51).

Expo DevClient iconExpo DevClient

A library that allows creating a development build and includes useful development tools.

Android
iOS

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

  • A configurable launcher UI, so you can launch updates (such as from PR previews) and switch between development servers without needing to recompile the native app
  • Improved debugging tools (such as support for inspecting network requests)
  • A powerful and extensible developer menu UI

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

Installation

Terminal
npx expo install expo-dev-client

If you are installing this in an existing React Native app (bare workflow), start by installing expo in your project. Then, follow the additional instructions as mentioned by library's README under "Installation in bare React Native projects" section.

Configuration in app.json/app.config.js

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-launcher",
        {
          "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.

API

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

Methods

Android
iOS

DevClient.closeMenu()

A method that closes development client menu when called.

Returns:

void

Android
iOS

DevClient.hideMenu()

A method that hides development client menu when called.

Returns:

void

Android
iOS

DevClient.isDevelopmentBuild()

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

Returns:

boolean

Android
iOS

DevClient.openMenu()

A method that opens development client menu when called.

Returns:

void

Android
iOS

DevClient.registerDevMenuItems(items)

NameType
itemsExpoDevMenuItem[]

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

Returns:

Promise<void>

Types

Android
iOS

ExpoDevMenuItem

An object representing the custom development client menu entry.

NameTypeDescription
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
Expo 中文网 - 粤ICP备13048890号