Skip to content

Conversation

@natew
Copy link
Contributor

@natew natew commented Jan 6, 2026

Summary

Exports the getDevServer function and DevServerInfo type from React Native's public API, making them available without deep imports.

Motivation

Deep imports are deprecated in v0.80 and will be removed in v0.82. Library authors currently rely on internal imports to use getDevServer:

// Current (deprecated)
import getDevServer from 'react-native/Libraries/Core/Devtools/getDevServer'

// After this PR
import { getDevServer, DevServerInfo } from 'react-native'

Use Cases

  • HMR clients: Tools like vxrn use getDevServer() to establish WebSocket connections to the dev server for hot module replacement
  • Dev tooling: Libraries need to know the dev server URL for error symbolication, bundle loading, and debugging features
  • URL resolution: Getting the base URL for fetching assets and making requests to the packager

The function is already used internally by React Native for:

  • symbolicateStackTrace.js - Error stack symbolication
  • loadBundleFromServer.js - Dynamic bundle loading
  • openFileInEditor.js - Opening source files in editor
  • React DevTools connection setup

Changelog:

[GENERAL] [ADDED] - Export getDevServer function and DevServerInfo type from public API

Test Plan

This is a straightforward export addition. The function already exists and is well-tested internally. Consumers can now import it directly:

import { getDevServer } from 'react-native';

const { url, bundleLoadedFromServer } = getDevServer();
console.log('Dev server URL:', url);

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 6, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jan 6, 2026
@huntie
Copy link
Member

huntie commented Jan 7, 2026

Hey @natew!

Gut reaction here is I don't think we want to expose these on the public 'react-native' import path. However, there is scope to put these under a new 'react-native/devsupport' (or potentially '@react-native/devsupport') entry point, which is being considered (or at least I am planning to open an RFC for soon enough). This PR adds extra motivation for that design.

It should be fine for your library to continue to use this subpath export for the forseeable future (note that these warnings will not propagate to consuming apps). We missed the 0.82 target as the community needed more time, and indeed we had extra APIs to solve, like the above plan.

Please stay tuned 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants