Skip to main content
rule official · GitHub

pcf-react-platform-libraries — GitHub Copilot rule

This rule guides GitHub Copilot through building React-based PCF controls with Power Apps platform libraries. Use it when setting up virtual controls for canvas or model-driven apps.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/instructions/pcf-react-platform-libraries.instructions.md
Open on GitHub

What pcf-react-platform-libraries does

The rule applies to ts, tsx, js, json, xml, pcfproj, and csproj files. It covers initializing a React project with pac pcf init -fw react, editing the control manifest, and rendering through ReactControl.updateView. React and Fluent are supplied as shared platform libraries, so the control package does not bundle its own copies.

Visual Studio Code and Microsoft Power Platform CLI are prerequisites. The rule also explains that React controls use the virtual control type and that init does not take a DOM element. An existing standard control cannot be converted by changing its type; create a new React control instead. Power Pages does not support these controls, which are intended for canvas and model-driven apps.

What it helps with

  • start a React PCF project with pac pcf init
  • configure the manifest to use shared React and Fluent libraries
  • render a control through ReactControl.updateView
  • understand how virtual React controls differ from standard controls

Example prompts for the agent

  • Create a React PCF project with pac pcf init and explain the command options.
  • Review the manifest and index.ts for a virtual React control using platform libraries.
  • Can this React control run in Power Pages? Explain the limitation.

How to install pcf-react-platform-libraries

Manually: put the files in place

.github/instructions/pcf-react-platform-libraries.instructions.md

The applyTo field sets which files it applies to

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about pcf-react-platform-libraries

How do I install pcf-react-platform-libraries in GitHub Copilot?

Add the rule file to your project at .github/instructions/pcf-react-platform-libraries.instructions.md.

What does pcf-react-platform-libraries do?

It guides setup of React PCF controls that use shared platform libraries, including manifest changes and rendering with ReactControl.updateView.

Are these controls supported in Power Pages?

No. React controls with platform libraries are supported in canvas and model-driven apps, not Power Pages.

Source text

pcf-react-platform-libraries.instructions.md · MIT
---
description: 'React controls and platform libraries for PCF components'
applyTo: '**/*.{ts,tsx,js,json,xml,pcfproj,csproj}'
---

# React Controls & Platform Libraries

When you use React and platform libraries, you're using the same infrastructure used by the Power Apps platform. This means you no longer have to package React and Fluent libraries individually for each control. All controls share a common library instance and version to provide a seamless and consistent experience.

## Benefits

By reusing the existing platform React and Fluent libraries, you can expect:

- **Reduced control bundle size**
- **Optimized solution packaging**
- **Faster runtime transfer, scripting, and control rendering**
- **Design and theme alignment with the Power Apps Fluent design system**

> **Note**: With GA release, all existing virtual controls will continue to function. However, they should be rebuilt and deployed using the latest CLI version (>=1.37) to facilitate future platform React version upgrades.

## Prerequisites

As with any component, you must install [Visual Studio Code](https://code.visualstudio.com/Download) and the [Microsoft Power Platform CLI](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/powerapps-cli#install-microsoft-power-platform-cli).

> **Note**: If you have already installed Power Platform CLI for Windows, make sure you are running the latest version by using the `pac install latest` command. The Power Platform Tools for Visual Studio Code should update automatically.

## Create a React Component

> **Note**: These instructions expect that you have created code components before. If you have not, see [Create your first component](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/implementing-controls-using-typescript).

There's a new `--framework` (`-fw`) parameter for the `pac pcf init` command. Set the value of this parameter to `react`.

### Command Parameters

| Parameter | Value |
|-----------|-------|
| --name | ReactSample |
| --namespace | SampleNamespace |
| --template | field |
| --framework | react |
| --run-npm-install | true (default) |

### PowerShell Command

The following PowerShell command uses the parameter shortcuts and creates a React component project and runs `npm-install`:

```powershell
pac pcf init -n ReactSample -ns SampleNamespace -t field -fw react -npm
```

You can now build and view the control in the test harness as usual using `npm start`.

After you build the control, you can package it inside solutions and use it for model-driven apps (including custom pages) and canvas apps like standard code components.

## Differences from Standard Components

### ControlManifest.Input.xml

The [control element](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/control) `control-type` attribute is set to `virtual` rather than `standard`.

> **Note**: Changing this value does not convert a component from one type to another.

Within the [resources element](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/resources), find two new [platform-library element](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference/platform-library) child elements:

```xml
<resources>
  <code path="index.ts" order="1" />
  <platform-library name="React" version="16.14.0" />
  <platform-library name="Fluent" version="9.46.2" />
</resources>
```

> **Note**: For more information about valid platform library versions, see Supported platform libraries list.

**Recommendation**: We recommend using platform libraries for Fluent 8 and 9. If you don't use Fluent, you should remove the `platform-library` element where the `name` attribute value is `Fluent`.

### Index.ts

The [ReactControl.init](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/react-control/init) method for control initialization doesn't have `div` parameters because React controls don't render the DOM directly. Instead [ReactControl.updateView](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/react-control/updateview) returns a ReactElement that has the details of the actual control in React format.

### bundle.js

React and Fluent libraries aren't included in the package because they're shared, therefore the size of bundle.js is smaller.

## Sample Controls

The following controls are included in the samples. They function the same as their standard versions but offer better performance since they are virtual controls.

| Sample | Description | Link |
|--------|-------------|------|
| ChoicesPickerReact | The standard ChoicesPickerControl converted to be a React Control | ChoicesPickerReact Sample |
| FacepileReact | The ReactStandardControl converted to be a React Control | FacepileReact |

## Supported Platform Libraries List

Platform libraries are made available both at the build and runtime to the controls that are using platform libraries capability. Currently, the following versions are provided by the platform and are the highest currently supported versions.

| Library | Package | Build Version | Runtime Version |
|---------|---------|---------------|-----------------|
| React | react | 16.14.0 | 17.0.2 (Model), 16.14.0 (Canvas) |
| Fluent | @fluentui/react | 8.29.0 | 8.29.0 |
| Fluent | @fluentui/react | 8.121.1 | 8.121.1 |
| Fluent | @fluentui/react-components | >=9.4.0 <=9.46.2 | 9.68.0 |

> **Note**: The application might load a higher compatible version of a platform library at runtime, but the version might not be the latest version available. Fluent 8 and Fluent 9 are each supported but can not both be specified in the same manifest.

## FAQ

### Q: Can I convert an existing standard control to a React control using platform libraries?

A: No. You must create a new control using the new template and then update the manifest and index.ts methods. For reference, compare the standard and react samples described above.

### Q: Can I use React controls & platform libraries with Power Pages?

A: No. React controls & platform libraries are currently only supported for canvas and model-driven apps. In Power Pages, React controls don't update based on changes in other fields.

## Related Articles

- [What are code components?](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/custom-controls-overview)
- [Code components for canvas apps](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/component-framework-for-canvas-apps)
- [Create and build a code component](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/create-custom-controls-using-pcf)
- [Learn Power Apps component framework](https://learn.microsoft.com/en-us/training/paths/use-power-apps-component-framework)
- [Use code components in Power Pages](https://learn.microsoft.com/en-us/power-apps/maker/portals/component-framework)

© github · MIT · github/awesome-copilot

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set861

The whole set →
php-mcp-server Instructions for GitHub Copilot on developing Model Context Protocol servers in PHP 8.2+. Guides the assistant to use official SDK attributes and clean project structures. ★ 40,418repo stars performance-optimization This rule helps spot web performance issues tied to Core Web Vitals and review possible fixes. Use it when working on page loading, rendering, or layout stability. ★ 40,418repo stars pcf-tooling A rule that tells Copilot to use Microsoft Power Platform CLI for building, debugging and deploying Power Apps code components. ★ 40,418repo stars pcf-sample-components Guides GitHub Copilot through preparing, building, and bundling Power Apps Component Framework samples into deployable solution archives. ★ 40,418repo stars pcf-overview Guides GitHub Copilot on Power Apps Component Framework architecture. Helps generate code components for canvas and model-driven applications. ★ 40,418repo stars pcf-model-driven-apps Teaches GitHub Copilot how to build and update code components for model-driven apps. Applies to ts, tsx, js, json, xml, pcfproj and csproj files. ★ 40,418repo stars pcf-manifest-schema A rule that feeds Copilot the structure of ControlManifest.Input.xml: which elements and attributes exist and what they do. Useful when editing a PCF component manifest. ★ 40,418repo stars pcf-limitations Instructs GitHub Copilot on Power Apps Component Framework restrictions. It prevents unsupported API calls and insecure storage patterns in PCF projects. ★ 40,418repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor