Power BI Client for Vue.js

1.1.2 · active · verified Wed Apr 22

powerbi-client-vue-js is a lightweight Vue.js wrapper library designed to streamline the integration of Microsoft Power BI reports, dashboards, and tiles into Vue applications. It provides high-level Vue components that abstract the complexities of directly interacting with the underlying `powerbi-client` JavaScript library, enabling developers to declaratively embed Power BI content. The current stable version is `1.1.2`. The project maintains an active release cadence, typically providing updates every few months to introduce new features, address bugs, and update dependencies. Its primary differentiator is the seamless integration with Vue's reactivity system, offering a more 'Vue-idiomatic' approach to Power BI embedding compared to direct SDK usage.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart embeds a Power BI report into a Vue.js component using the PowerBIReport component, configuring its essential properties like ID, embed URL, and access token, while providing basic styling for the container.

<template>
  <div class="powerbi-embed-container">
    <PowerBIReport
      :embedConfig="reportConfig"
      :cssClassName="'my-powerbi-report'"
      :phasedEmbedding="false"
    />
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { PowerBIReport } from 'powerbi-client-vue-js';
import { models } from 'powerbi-client'; // Import models for tokenType and settings

export default defineComponent({
  name: 'EmbedPowerBIReport',
  components: {
    PowerBIReport,
  },
  setup() {
    const reportConfig = ref({
      type: 'report',
      id: 'YOUR_REPORT_ID', // Replace with your Power BI Report ID
      embedUrl: 'YOUR_EMBED_URL', // Replace with your Power BI Embed URL
      accessToken: process.env.VUE_APP_PBI_ACCESS_TOKEN ?? '', // Fetch securely, e.g., from an API
      tokenType: models.TokenType.Embed,
      settings: {
        filterPaneEnabled: true,
        navContentPaneEnabled: true,
        layoutType: models.LayoutType.Custom, // Example layout type
        customLayout: {
          displayOption: models.DisplayOption.FitToPage
        }
      }
    });

    return {
      reportConfig,
    };
  },
});
</script>

<style>
.powerbi-embed-container {
  height: 600px; /* Ensure container has height for Power BI embed */
  width: 100%;
  border: 1px solid #ccc;
}
.my-powerbi-report {
  height: 100%;
  width: 100%;
}
</style>

view raw JSON →