Deploy React PCF Controls Across Power Apps Environments Without Breaking Solutions
By Mirko Peters · · Updated
How to package and deploy React code components (PCF) across environments: virtual controls and platform libraries, managed release builds, versioning, canvas app updates and dependency pitfalls.
A React code component deploys like any other Power Apps component framework (PCF) control, with three differences: it is a virtual control that relies on platform-provided libraries, it must be built in production mode, and canvas apps need an explicit update step. Most broken deployments come from shipping a development build, forgetting to raise the version, or importing a dependent solution before the component solution. This guide follows the Microsoft Learn pages listed under Sources.
Key points
- React controls use the platform's React and Fluent libraries. The manifest sets control-type to virtual and lists platform-library entries.
- Do not deploy development builds. Set PcfBuildMode to production and package as Managed for every non-development environment.
- Raise at least the PATCH version in the control manifest, or the change is not detected. Keep MAJOR and MINOR in sync with the solution.
- Canvas apps keep the old component version until the maker opens the app, selects Update on the Update code components dialog, saves and publishes.
- A solution that depends on a segmented component solution can only be imported after that component solution is installed in the target.
What a React control changes
Microsoft Learn says React code components use the same React and Fluent libraries that the platform provides, so each control no longer packages them. This reduces bundle size and aligns the control with the platform theme.
To create one:
``powershell pac pcf init -n ReactSample -ns SampleNamespace -t field -fw react -npm ``
Manifest changes:
- Set
control-type="virtual"instead ofstandard. This does not convert an existing component. - Add platform libraries under
resources, for example<platform-library name="React" version="16.14.0" />and<platform-library name="Fluent" version="9.46.2" />. Remove the Fluent element if Fluent is not used. The manifest accepts Fluent 8 or Fluent 9, not both.
Learn lists the allowed React version as 16.14.0, with 17.0.2 loaded in model-driven apps and 16.14.0 in canvas apps. The app might load a higher compatible version of a library at runtime. Limits: you cannot convert an existing standard control, and React controls are not supported in Power Pages.
Step 1: Enable the framework for canvas apps
Model-driven apps have the component framework on by default. For canvas apps, a system administrator must turn on Power Apps component framework for canvas apps in the environment: Settings > Admin Center > Environments > the environment > Settings > Product > Features. Repeat this in every target environment. A Power Apps license is required, and Learn warns that code components are not generated by Microsoft, so only add solutions from trusted sources.
Step 2: Build for production
Learn says a component built in development mode is often too large to import and may perform slower. The build modes:
| Command | Result | |---|---| | npm start watch | Always development | | pac pcf push | Development by default. Production when PcfBuildMode is production | | npm run build | Development by default | | npm run build -- --buildMode production | Release build |
To make pac pcf push build for release, add <PcfBuildMode>production</PcfBuildMode> to the pcfproj. The page itself writes both production and release for the flag in different places and does not say whether they differ, so check your output size.
Step 3: Package as a solution
The solution project steps from Learn:
- Create a
Solutionsfolder and runpac solution init --publisher-name <name> --publisher-prefix <prefix>. - Run
pac solution add-reference --path <component folder>. - Build with
msbuild /t:restoreandmsbuild, ordotnet buildwith .NET SDK 6 or later. - Collect the generated files from
\bin\debug\.
The configuration decides the package type. Debug creates an unmanaged solution, Release creates a managed one. This can be overridden by the SolutionPackageType property in the cdsproj. Use msbuild /p:configuration=Release for a release build.
Learn's ALM guidance says managed solutions are used for any environment that is not a development environment for that solution, including test, UAT, SIT and production.
Step 4: Version correctly
- In
ControlManifest.Input.xml, at least the PATCH part must be raised, or the change is not detected.pac pcf version --strategy manifestor--patchversionhelps. - Solution versions use
MAJOR.MINOR.BUILD.REVISION. Learn recommends keeping MAJOR and MINOR of the control in sync with the solution. - Versioning lets canvas apps detect updates and lets model-driven apps invalidate their cache.
Step 5: Choose a solution strategy
Learn describes two:
- Segmented solutions. A separate component solution that others depend on. It suits a separate versioning lifecycle or shared use across environments.
- Single solution. Components sit with tables and apps. Branching matters here, so one part can be deployed without taking unfinished changes from another.
With a segmented approach, the component solution must be installed in the target before a dependent solution can be imported. Missing items appear in the MissingDependencies section as type 66.
Step 6: Import and update canvas apps
Import manually through the maker portal or automatically with Power Platform Build Tools or GitHub Actions. For canvas apps, Learn recommends deploying the same control version first or in the same solution, and importing an app without its component is possible but not recommended.
After a new control version arrives, the maker opens the app in Power Apps Studio, selects Update on the Update code components dialog, then saves and publishes. Without this, the app keeps using the older version even though it was overwritten. Different versions cannot run side by side in one app. Publishing all customizations in the updated solution first is also required, or updates do not show.
Step 7: Keep source control clean
Commit the pcfproj and cdsproj. The standard .gitignore excludes /node_modules, **/generated, /out, /bin and /obj, so bundle.js is not in source control. Commit unpacked solutions in unmanaged form, since managed-only metadata makes new development environments hard to create. Learn also says pac pcf push is for development and uses a temporary PowerAppsTools solution unless --solution-unique-name is given. The publisher must match.
What the pages do not cover
Learn does not describe how a platform library update changes already deployed React controls, nor pac auth and solution layering in this ALM article. Test after platform releases and use your normal environment pipeline.
Typical mistakes
- Deploying output of
pac pcf pushwithout production mode. - Forgetting the PATCH increment.
- Importing a dependent solution before the component solution.
- Skipping the canvas Update prompt.
- Forgetting to enable the feature in the target environment.
Related
Sources
- React controls and platform libraries (Microsoft Learn)
- Package and deploy a code component (Microsoft Learn)
- Code components application lifecycle management (Microsoft Learn)
- Code components for canvas apps (Microsoft Learn)
FAQ
What makes a PCF control a React control?
Microsoft Learn says to create it with pac pcf init using the framework parameter set to react, set control-type to virtual in the manifest and add platform-library entries for React and, if used, Fluent. The package then excludes React and Fluent because the platform shares them.
Which build do I deploy to test and production?
Microsoft Learn says not to normally deploy a development build into Dataverse, because it is often too large to import and may run slower. Use a production build, and use managed solutions for any environment that is not a development environment for that solution.
Why does my canvas app still show the old control after deployment?
Learn explains that the maker must open the app in Power Apps Studio, select Update on the Update code components dialog, then save and publish. Otherwise the app keeps using the older version, even though it has been overwritten in the environment.
Do React controls work in Power Pages?
No. The React controls article lists Power Pages as unsupported. React controls and platform libraries work only with canvas and model-driven apps.
Does Learn describe how platform library updates affect deployed solutions?
Not in the pages read. The React article only states that the package excludes React and Fluent and that the app might load a higher compatible version at runtime than the one listed. Test after each platform update.