This library provides a React wrapper for the underlying `powerbi-client` JavaScript library, enabling seamless integration of various Power BI artifacts—reports, dashboards, tiles, visuals, Q&A, and paginated reports—directly within React applications. It also facilitates the creation of new Power BI reports within the application context. The current stable version is 2.0.2, with recent major updates like v2.0.0 upgrading the peer dependency to React 18, which introduced breaking changes for older React environments. Release cadence is driven by feature additions, bug fixes, and compatibility updates, without a strict schedule but maintaining active development. Its key differentiators include a declarative, component-based API that simplifies embedding compared to direct `powerbi-client` usage, built-in lifecycle management, and support for advanced features like report bootstrapping for performance optimization and dynamic configuration updates.
npm install powerbi-client-reactVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to embed a Power BI report into a React component, including basic configuration, event handling, and accessing the embedded component reference. It uses environment variables for secure access.
Upgrade your React application to React 18 or higher. If unable to upgrade, use `powerbi-client-react` v1.x.
Review existing code that relies on dynamic updates to `embedConfig` and ensure it behaves as expected with the new re-embed fix. No specific code fix is generally required as this corrects previous buggy behavior.
Always explicitly import `models` using `import * as models from 'powerbi-client';` when needed in your components.
After initial bootstrap, ensure your component's state or props are updated with the necessary `accessToken`, `embedUrl`, and `id` to trigger the actual embedding process.
Always use `new Map([...])` for the `eventHandlers` prop, e.g., `eventHandlers={new Map([['loaded', () => {...}]])}`.Upgrade React and ReactDOM to version 18.x in your project (`npm install react@^18 react-dom@^18` or `yarn add react@^18 react-dom@^18`).
Add `import * as models from 'powerbi-client';` to your component file.
Ensure your event handler function correctly inspects the `event` object's structure as per `powerbi-client` documentation. Not all events might have a `detail` property, or it might be null.
Verify that `embedConfig.accessToken`, `embedConfig.embedUrl`, and `embedConfig.id` are correctly populated with valid, non-empty string values from your Power BI embedding service.