0.76.1 • Published 7 months ago

@react-native/dev-middleware v0.76.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@react-native/dev-middleware

npm package

Dev server middleware supporting core React Native development features. This package is preconfigured in all React Native projects.

Usage

Middleware can be attached to a dev server (e.g. Metro) using the createDevMiddleware API.

import { createDevMiddleware } from '@react-native/dev-middleware';

function myDevServerImpl(args) {
  ...

  const {middleware, websocketEndpoints} = createDevMiddleware({
    projectRoot: metroConfig.projectRoot,
    serverBaseUrl: `http://${args.host}:${args.port}`,
    logger,
  });

  await Metro.runServer(metroConfig, {
    host: args.host,
    ...,
    unstable_extraMiddleware: [
      middleware,
      // Optionally extend with additional HTTP middleware
    ],
    websocketEndpoints: {
      ...websocketEndpoints,
      // Optionally extend with additional WebSocket endpoints
    },
  });
}

Included middleware

@react-native/dev-middleware is designed for integrators such as @expo/dev-server and @react-native/community-cli-plugin. It provides a common default implementation for core React Native dev server responsibilities.

We intend to keep this to a narrow set of functionality, based around:

  • Debugging — The Chrome DevTools protocol (CDP) endpoints supported by React Native, including the Inspector Proxy, which facilitates connections with multiple devices.
  • Dev actions — Endpoints implementing core Dev Menu actions, e.g. reloading the app, opening the debugger frontend.

HTTP endpoints

DevMiddlewareAPI.middleware

These are exposed as a connect middleware handler, assignable to Metro.runServer or other compatible HTTP servers.

GET /json/list, /json (CDP)

Returns the list of available WebSocket targets for all connected React Native app sessions.

GET /json/version (CDP)

Returns version metadata used by Chrome DevTools.

GET /debugger-frontend

Subpaths of this endpoint are reserved to serve the JavaScript debugger frontend.

POST /open-debugger

Open the JavaScript debugger for a given CDP target (direct Hermes debugging).

curl -X POST 'http://localhost:8081/open-debugger?appId=com.meta.RNTester'

WebSocket endpoints

DevMiddlewareAPI.websocketEndpoints

/inspector/device

WebSocket handler for registering device connections.

/inspector/debug

WebSocket handler that proxies CDP messages to/from the corresponding device.

Contributing

Changes to this package can be made locally and tested against the rn-tester app, per the Contributing guide. During development, this package is automatically run from source with no build step.

0.76.1

8 months ago

0.76.0

8 months ago

0.76.0-rc.6

8 months ago

0.76.0-rc.5

8 months ago

0.76.0-rc.3

9 months ago

0.76.0-rc.4

8 months ago

0.74.88

8 months ago

0.75.4

8 months ago

0.76.0-rc.2

9 months ago

0.76.0-rc.1

9 months ago

0.76.0-rc.0

9 months ago

0.75.3

9 months ago

0.74.87

10 months ago

0.74.85

12 months ago

0.74.86

11 months ago

0.75.2

10 months ago

0.74.84

1 year ago

0.75.1

10 months ago

0.75.0

10 months ago

0.75.0-rc.1

12 months ago

0.75.0-rc.0

12 months ago

0.75.0-rc.5

11 months ago

0.75.0-rc.4

11 months ago

0.75.0-rc.3

12 months ago

0.75.0-rc.2

12 months ago

0.75.0-rc.7

10 months ago

0.75.0-rc.6

11 months ago

0.74.83

1 year ago

0.74.82

1 year ago

0.74.81

1 year ago

0.74.80

1 year ago

0.74.79

1 year ago

0.74.78

1 year ago

0.74.77

1 year ago

0.74.76

1 year ago

0.74.75

1 year ago

0.75.0-main

1 year ago

0.74.3

1 year ago

0.74.2

1 year ago

0.74.1

1 year ago

0.73.8

1 year ago

0.73.7

1 year ago

0.73.6

1 year ago

0.73.5

2 years ago

0.73.4

2 years ago

0.74.0

2 years ago

0.73.3

2 years ago

0.73.2

2 years ago

0.73.0

2 years ago