{"name":"@react-native/dev-middleware","version":"0.77.0-rc.5","keywords":["react-native","tools"],"license":"MIT","_id":"@react-native/dev-middleware@0.77.0-rc.5","homepage":"https://github.com/facebook/react-native/tree/HEAD/packages/dev-middleware#readme","bugs":{"url":"https://github.com/facebook/react-native/issues"},"dist":{"shasum":"6ef6a8186374ad678565ea5d05ca1c9c46f6dcb8","tarball":"http://registry-npm.ywwl.com/@react-native/dev-middleware/download/@react-native/dev-middleware-0.77.0-rc.5.tgz","fileCount":53,"integrity":"sha512-6aAn0npRs820G+g8hnmyDTH1FU/y/YC63PaRPQW29U/0Qmzu5JxkYxMU0naJTiAYTkZNS23CyaoCX/GqRLtknQ==","signatures":[{"sig":"MEUCIQDX0YmHQ31PoJgTbwkyFtgWrCedm7fHoj+QLC/AWNGCGgIgFx5XkIoMx7u1gRyl/VQyLlBTeFIF7z4WMyHDUisUOEk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":103355,"size":24400,"noattachment":false,"key":"/@react-native/dev-middleware/-/@react-native/dev-middleware-0.77.0-rc.5.tgz"},"engines":{"node":">=18"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"gitHead":"9d472ae28db901906f94cf2a175e0a3675471165","_npmUser":{"name":"react-native-bot","email":"opensource+react-native-bot@fb.com"},"repository":{"url":"git+https://github.com/facebook/react-native.git","type":"git","directory":"packages/dev-middleware"},"_npmVersion":"10.8.2","description":"Dev server middleware for React Native","directories":{},"_nodeVersion":"18.20.5","dependencies":{"ws":"^6.2.3","open":"^7.0.3","debug":"^2.2.0","connect":"^3.6.5","nullthrows":"^1.1.1","selfsigned":"^2.4.1","serve-static":"^1.16.2","chrome-launcher":"^0.15.2","@isaacs/ttlcache":"^1.4.1","chromium-edge-launcher":"^0.2.0","@react-native/debugger-frontend":"0.77.0-rc.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"undici":"^5.27.2","wait-for-expect":"^3.0.2","data-uri-to-buffer":"^6.0.1"},"_npmOperationalInternal":{"tmp":"tmp/dev-middleware_0.77.0-rc.5_1735585708375_0.5765230858627886","host":"s3://npm-registry-packages-npm-production"},"readme":"# @react-native/dev-middleware\n\n![npm package](https://img.shields.io/npm/v/@react-native/dev-middleware?color=brightgreen&label=npm%20package)\n\nDev server middleware supporting core React Native development features. This package is preconfigured in all React Native projects.\n\n## Usage\n\nMiddleware can be attached to a dev server (e.g. [Metro](https://facebook.github.io/metro/docs/getting-started)) using the `createDevMiddleware` API.\n\n```js\nimport { createDevMiddleware } from '@react-native/dev-middleware';\n\nfunction myDevServerImpl(args) {\n  ...\n\n  const {middleware, websocketEndpoints} = createDevMiddleware({\n    projectRoot: metroConfig.projectRoot,\n    serverBaseUrl: new URL(`http://${args.host}:${args.port}`),\n    logger,\n  });\n\n  await Metro.runServer(metroConfig, {\n    host: args.host,\n    ...,\n    unstable_extraMiddleware: [\n      middleware,\n      // Optionally extend with additional HTTP middleware\n    ],\n    websocketEndpoints: {\n      ...websocketEndpoints,\n      // Optionally extend with additional WebSocket endpoints\n    },\n  });\n}\n```\n\n## Included middleware\n\n`@react-native/dev-middleware` is designed for integrators such as [`@expo/dev-server`](https://www.npmjs.com/package/@expo/dev-server) and [`@react-native/community-cli-plugin`](https://github.com/facebook/react-native/tree/main/packages/community-cli-plugin). It provides a common default implementation for core React Native dev server responsibilities.\n\nWe intend to keep this to a narrow set of functionality, based around:\n\n- **Debugging** — The [Chrome DevTools protocol (CDP)](https://chromedevtools.github.io/devtools-protocol/) endpoints supported by React Native, including the Inspector Proxy, which facilitates connections with multiple devices.\n- **Dev actions** — Endpoints implementing core [Dev Menu](https://reactnative.dev/docs/debugging#accessing-the-dev-menu) actions, e.g. reloading the app, opening the debugger frontend.\n\n### HTTP endpoints\n\n<small>`DevMiddlewareAPI.middleware`</small>\n\nThese are exposed as a [`connect`](https://www.npmjs.com/package/connect) middleware handler, assignable to `Metro.runServer` or other compatible HTTP servers.\n\n#### GET `/json/list`, `/json` ([CDP](https://chromedevtools.github.io/devtools-protocol/#endpoints))\n\nReturns the list of available WebSocket targets for all connected React Native app sessions.\n\n#### GET `/json/version` ([CDP](https://chromedevtools.github.io/devtools-protocol/#endpoints))\n\nReturns version metadata used by Chrome DevTools.\n\n#### GET `/debugger-frontend`\n\nSubpaths of this endpoint are reserved to serve the JavaScript debugger frontend.\n\n#### POST `/open-debugger`\n\nOpen the JavaScript debugger for a given CDP target. Must be provided with one of the following query params:\n\n- `device`‌ — An ID unique to a combination of device and app, stable across installs. Implemented by `getInspectorDeviceId` on each native platform.\n- `target` — The target page ID as returned by `/json/list` for the current dev server session.\n- `appId` (deprecated, legacy only) — The application bundle identifier to match (non-unique across multiple connected devices). This param will only match legacy Hermes debugger targets.\n\n<details>\n<summary>Example</summary>\n\n    curl -X POST 'http://localhost:8081/open-debugger?target=<targetId>'\n</details>\n\n### WebSocket endpoints\n\n<small>`DevMiddlewareAPI.websocketEndpoints`</small>\n\n#### `/inspector/device`\n\nWebSocket handler for registering device connections.\n\n#### `/inspector/debug`\n\nWebSocket handler that proxies CDP messages to/from the corresponding device.\n\n## Experimental features\n\nReact Native frameworks may pass an `unstable_experiments` option to `createDevMiddleware` to configure experimental features. Note that these features might not work correctly, and they may change or be removed in the future without notice. Some of the experiment flags available are documented below.\n\n### `unstable_experiments.enableStandaloneFuseboxShell`\n\nEnables launching the debugger frontend in a standalone app shell (provided by the `@react-native/debugger-shell` package) rather than in a browser window. Since React Native 0.83 this defaults to `true`, and may be disabled by explicitly passing `false`.\n\nThe shell is powered by a separate binary that is downloaded and cached in the background (immediately after the call to `createDevMiddleware`). If there is a problem downloading or invoking this binary for the first time, the debugger frontend will revert to launching in a browser window until the next time `createDevMiddleware` is called (typically, on the next dev server start).\n\n## Contributing\n\nChanges to this package can be made locally and tested against the `rn-tester` app, per the [Contributing guide](https://reactnative.dev/contributing/overview#contributing-code). During development, this package is automatically run from source with no build step.\n","publish_time":1735585708574,"maintainers":[{"name":"react-native-bot","email":"opensource+react-native-bot@fb.com"},{"name":"fb","email":"opensource+npm@fb.com"}],"_cnpm_publish_time":1735585708574,"dist-tags":{"0.74-stable":"0.74.89","0.75-stable":"0.75.5","0.76-stable":"0.76.9","0.77-stable":"0.77.3","0.78-stable":"0.78.3","0.79-stable":"0.79.7","0.80-stable":"0.80.3","0.81-stable":"0.81.6","0.83-stable":"0.83.10","0.86-stable":"0.86.3","false":"0.74.82","latest":"0.88.1","next":"0.89.0-rc.3","nightly":"0.90.0-nightly-20261127-7a2d1d257"}}