You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-41Lines changed: 47 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
This is a sample project for using MFEs with an Angular host and a React remote, using Nx.
4
4
5
-
All code is provided in the GitHub repo [mfe-angular-react-nx](https://github.com/angularexample/mfe-angular-react-nx).
5
+
All code is provided in the GitHub repo [https://github.com/angularexample/mfe-angular-react-nx](https://github.com/angularexample/mfe-angular-react-nx).
6
6
7
7
It includes step-by-step instructions for creating the project.
8
8
@@ -14,13 +14,13 @@ August 22, 2025
14
14
15
15
At the time of this writing, it used the latest versions provided by Nx
16
16
17
-
* Nx 21.4.1
18
17
* Angular 20.1.0
19
18
* React 19.0.0
19
+
* Nx 21.4.1
20
20
21
21
## About The Author
22
22
23
-
```JC Lango``` is a UI Architect and Developer for many large-scale web applications at several well-known Fortune 500 companies.
23
+
`JC Lango` is a UI Architect and Developer for many large-scale web applications at several well-known Fortune 500 companies.
24
24
25
25
He is an expert in **Angular** and **React** and maintains these sites at GitHub:
26
26
@@ -69,10 +69,10 @@ Open a terminal window, go to the base directory where you want the new workspac
* In this case, **4202** is the port address for the second remote application.
235
240
@@ -243,29 +248,30 @@ If you want to create a React remote application, you will need to use the Nx Re
243
248
244
249
Generate the React remote application using the @nx/react package.
245
250
251
+
```
252
+
nx g @nx/react:remote apps/remote3 --style=scss --e2eTestRunner=playwright --bundler=webpack
253
+
```
254
+
246
255
See the Nx documentation for more information on the [React Remote App Generator Options](https://nx.dev/technologies/react/api/generators/remote#options)
247
256
248
-
Add the following command line options.
257
+
We are using the following command line options:
249
258
250
259
* --style=scss
251
260
* --e2eTestRunner=playwright
252
261
* --bundler=webpack
253
262
254
263
If you provide a path name for the remote application, you don't need the name or directory options.
255
264
256
-
In this case, ```remote3``` is the name, and ```apps``` is the directory.
265
+
In this case, `remote3` is the name, and `apps` is the directory.
257
266
258
-
**NOTE: Do not supply the ```--host``` option.**
267
+
**NOTE: Do not supply the `--host` option.**
259
268
260
269
Since the host is an Angular application, the generation step will fail.
261
270
The Nx generator does not support mixing different frameworks in MFEs.
262
271
263
272
You will need to configure the remote application to the host manually.
264
273
We will provide detailed instructions later in this document.
265
274
266
-
```
267
-
nx g @nx/react:remote apps/remote3 --style=scss --e2eTestRunner=playwright --bundler=webpack
268
-
```
269
275
270
276
### Build and Run the Remote Application
271
277
@@ -312,7 +318,7 @@ There are several steps to manually add the React remote application to the Angu
@@ -354,19 +360,19 @@ It can only be used with React 18 or newer.
354
360
355
361
Open the React remote app component.
356
362
357
-
```apps/remote3/src/app/app.tsx```
363
+
`apps/remote3/src/app/app.tsx`
358
364
359
-
Import the ```r2wc``` function from the package.
365
+
Import the `r2wc` function from the package.
360
366
361
367
```typescript
362
368
importr2wcfrom'@r2wc/react-to-web-component';
363
369
```
364
370
365
-
In your React component, after the ```App()``` function,
371
+
In your React component, after the `App()` function,
366
372
add a function to convert the component to a Web Component.
367
373
368
374
You will need to supply a new element name for the Web Component.
369
-
In this case, we will use the name ```wc-remote3```.
375
+
In this case, we will use the name `wc-remote3`.
370
376
371
377
```typescript
372
378
exportfunction defineReactWebComponent() {
@@ -391,7 +397,7 @@ export default App;
391
397
392
398
We need an Angular component to wrap the React Web Component.
393
399
394
-
We will call this component ```react-wrapper```.
400
+
We will call this component `react-wrapper`.
395
401
396
402
In the Angular host app, create a new directory using the same name as the component, in the src/app directory, and create the component, using the Nx Angular component generator.
397
403
@@ -401,17 +407,17 @@ nx g @nx/angular:component apps/host/src/app/react-wrapper/react-wrapper
0 commit comments