|
| 1 | +--- |
| 2 | +id: migration-guide |
| 3 | +title: Migration Guide |
| 4 | +--- |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +### React Native Windows — Migration from Paper (Old Architecture) to Fabric (New Architecture) - Sample Calculator App |
| 9 | + |
| 10 | + |
| 11 | +### Introduction |
| 12 | + |
| 13 | +React Native 0.80 introduces Fabric as the default renderer and completes the transition to the New Architecture (Fabric + TurboModules). For React Native Windows (RNW), this migration replaces the legacy Paper architecture with a modern rendering pipeline that improves performance and memory usage. |
| 14 | + |
| 15 | +> **Note:** This documentation references RNW v0.80, since Fabric becomes the default renderer starting with this version. However, the migration guide can be generally referred to for migrating from Paper to Fabric beginning with RNW versions supporting Fabric (starting RNW v0.74). |
| 16 | +
|
| 17 | +### Key Concepts |
| 18 | + |
| 19 | + |
| 20 | +- Paper (Old Architecture): Legacy renderer that uses UIManager and bridge-based communication between JS and native. |
| 21 | + |
| 22 | +- Fabric (New Architecture): Modern concurrent renderer built on React Fiber and JSI. |
| 23 | + |
| 24 | +- TurboModules: New native module system that replaces the old bridge-based modules with JSI bindings. |
| 25 | + |
| 26 | +- RNW cpp-app Template: Default Windows template for new-architecture (Fabric) apps using C++/WinAppSDK. |
| 27 | + |
| 28 | +- RNW old-uwp/cpp-app Template: Legacy UWP template used for Paper-based (old architecture) apps. |
| 29 | + |
| 30 | + |
| 31 | +### Prerequisites |
| 32 | + |
| 33 | +- Node.js ≥ 18.x |
| 34 | + - React Native CLI ≥ 13.x |
| 35 | + - Visual Studio 2022 (v17.10 or later) |
| 36 | + - Windows SDK ≥ 10.0.22621.0 |
| 37 | + - Existing RNW app running on RN < 0.80 (Paper architecture) |
| 38 | + |
| 39 | +Run yarn install after every update of package.json file |
| 40 | + |
| 41 | +### RNW App Migration |
| 42 | + |
| 43 | +About the App: |
| 44 | + |
| 45 | +For the purposes of this migration guide, we will use the sample Calculator app from the [React-native-windows-samples repository](https://github.com/microsoft/react-native-windows-samples). This Calculator app demonstrates a straightforward React Native for Windows project implemented in C++/WinRT, making it well-suited for illustrating the steps required to move from the legacy Paper architecture to the modern Fabric architecture. The app covers basic UI, native modules, and integration patterns typical in RNW projects, providing a practical reference as you follow each migration step. |
| 46 | + |
| 47 | +You can view the Calculator app's source code at [react-native-windows-samples/samples/Calculator/cppwinrt](https://github.com/microsoft/react-native-windows-samples/tree/9e5d850e843acc2ff060fbd64673511cc67265f9/samples/Calculator/cppwinrt) and examine the full migration changes in the pull request diff [migrate calculator by anupriya13 · PR #1092](https://github.com/microsoft/react-native-windows-samples/pull/1092/files#diff-12ccc26d0186ecea507053fb04c1d4eac13aea210e5e1e95332e9add88940971). This real-world example enables you to compare the project structure and dependencies before and after the migration, making it easier to understand and replicate the process in your own RNW apps. |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +Repo: [react-native-windows-samples/samples/Calculator/cppwinrt at main · microsoft/react-native-windows-samples](https://github.com/microsoft/react-native-windows-samples/tree/main/samples/Calculator/cppwinrt) |
| 52 | + |
| 53 | +Sample Diff: [migrate calculator by anupriya13 · Pull Request #1092 · microsoft/react-native-windows-samples](https://github.com/microsoft/react-native-windows-samples/pull/1092/files#diff-12ccc26d0186ecea507053fb04c1d4eac13aea210e5e1e95332e9add88940971) |
| 54 | + |
| 55 | +Before you migrate confirm few things on your Paper project re-confirm that your project is using Paper architecture by checking the package.json init-window section |
| 56 | + |
| 57 | + |
| 58 | +### Steps Followed to Migrate to New Architecture (Fabric) |
| 59 | +- Upgrade Dependencies: Update package.json to use React Native 0.80 and run: |
| 60 | + ```bash |
| 61 | + npm install |
| 62 | + ``` |
| 63 | + or |
| 64 | + ```bash |
| 65 | + yarn install |
| 66 | + ``` |
| 67 | + (Reference - [react-native-windows-samples/samples/Calculator/cppwinrt/package.json at 9e5d850e843acc2ff060fbd64673511cc67265f9 · microsoft/react-native-windows-samples](https://github.com/microsoft/react-native-windows-samples/blob/9e5d850e843acc2ff060fbd64673511cc67265f9/samples/Calculator/cppwinrt/package.json)) |
| 68 | + |
| 69 | +- Delete the Existing Windows Directory: |
| 70 | + ```bash |
| 71 | + rm -rf windows |
| 72 | + ``` |
| 73 | + |
| 74 | +- Update Template in package.json: Set `"template": "cpp-app"` to use the new architecture template. |
| 75 | + |
| 76 | +- Run: |
| 77 | + ```bash |
| 78 | + yarn install |
| 79 | + ``` |
| 80 | + |
| 81 | +- Reinitialize the Windows Project: |
| 82 | + ```bash |
| 83 | + npx react-native init-windows --template cpp-app |
| 84 | + ``` |
| 85 | + |
| 86 | +- Run the Application: |
| 87 | + ```bash |
| 88 | + npx @react-native-community/cli run-windows |
| 89 | + ``` |
| 90 | + |
| 91 | + |
| 92 | +You will see new files created / updated inside windows directory |
| 93 | + |
| 94 | +No JS/TSX changes needed in src as Calculator uses basic components. |
| 95 | + |
| 96 | + |
| 97 | +Commit Paper to Fabric: [migrate calculator by anupriya13 · Pull Request #1092 · microsoft/react-native-windows-samples](https://github.com/microsoft/react-native-windows-samples/pull/1092/commits/773c0ddec708083ab3fbd93dca08acfe0aa408aa) |
| 98 | + |
| 99 | +### Reverting to Old Architecture (Paper) |
| 100 | + |
| 101 | +In case you encounter issues migrating to Fabric or due to unsupported controls or properties in Fabric please refer to below steps to revert back to Paper architecture. If you encounter missing properties, please open an issue: https://github.com/microsoft/react-native-windows/issues |
| 102 | + |
| 103 | +- Delete the Windows Directory: |
| 104 | + ```bash |
| 105 | + rm -rf windows |
| 106 | + ``` |
| 107 | + |
| 108 | +- Update Template in package.json: Set `"template": "old/uwp-cpp-app"`. (Reference -[react-native-windows-samples/samples/Calculator/fabric/package.json at 9e5d850e843acc2ff060fbd64673511cc67265f9 · microsoft/react-native-windows-samples](https://github.com/microsoft/react-native-windows-samples/blob/9e5d850e843acc2ff060fbd64673511cc67265f9/samples/Calculator/fabric/package.json)) |
| 109 | + |
| 110 | +- Run: |
| 111 | + ```bash |
| 112 | + yarn |
| 113 | + ``` |
| 114 | + |
| 115 | +- Reinitialize the Old Architecture Project: |
| 116 | + ```bash |
| 117 | + npx react-native init-windows --template old/uwp-cpp-app |
| 118 | + ``` |
| 119 | + |
| 120 | +- Run the App: |
| 121 | + ```bash |
| 122 | + npx @react-native-community/cli run-windows |
| 123 | + ``` |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +Commit Fabric to Paper for reference: [migrate calculator by anupriya13 · Pull Request #1092 · microsoft/react-native-windows-samples](https://github.com/microsoft/react-native-windows-samples/pull/1092/commits/450baba033b9c1f0e9b9e882bee91954f03767a1) |
| 128 | + |
| 129 | +### Third-Party Modules and Community Libraries [Out of Scope for Calculator] |
| 130 | + |
| 131 | +When migrating to the New Architecture (Fabric), it's important to verify that all third-party or community modules used in your project are compatible with the new architecture. Modules developed for the old Paper bridge may not function correctly without Fabric support. |
| 132 | + |
| 133 | +Before using any external module: |
| 134 | + |
| 135 | + Check the module's documentation or GitHub repository for Fabric or TurboModule support. |
| 136 | + |
| 137 | +Prefer modules that explicitly state compatibility with React Native 0.80 or higher. |
| 138 | + |
| 139 | +If the module is not updated, consider alternative libraries or maintain your own fork until Fabric support is added. |
| 140 | + |
| 141 | +### Flyout / Popup Behavior Update [Out of Scope for Calculator] |
| 142 | + |
| 143 | +In the New Architecture RNW, the Flyout and Popup components have been updated to align with the Modal API for better cross-platform consistency. Any previous usage of Flyout or Popup should be reviewed and replaced with the new Modal-based implementation, ensuring proper layering, dismissal, and accessibility behavior. |
| 144 | + |
| 145 | +### Conclusion |
| 146 | + |
| 147 | +Migrating from Paper to Fabric in React Native Windows modernizes your project, improves performance, and prepares your app for future React Native releases. Reverting to the old architecture is simple if required. |
0 commit comments