This tutorial will help you integrate Flexmonster with Nuxt. The integration process is similar to Flexmonster integration with Vue 3, except for a few Nuxt-specific steps.
npm install -g flexmonster-cli
Step 1. To get our sample project, download it as ZIP or clone it with the following commands:
git clone https://github.com/flexmonster/pivot-vue
cd pivot-vue/nuxt
Step 2. Install the project's dependencies:
npm install
Step 3. Run the sample project from the console:
npm start
Open the project in the browser to see the result.
To shut down the project from the console, press Ctrl + C (Control + C on macOS).
Our sample project was created using nuxi init, so most of the project’s files are typical of projects created this way. Learn more about the Nuxt directory structure.
Now take a look at the files specific to our sample project:
components/ — menus and toggle elements used in the sample project.plugins/flexmonster.client.js — a Nuxt client-side plugin for Flexmonster.app.css — CSS styles for the project.nuxt.config.ts — Nuxt configurations. The plugin for Flexmonster is registered here.pages/ — demos that cover different aspects of Flexmonster usage in Nuxt:<Pivot> component.Learn more about how these demos work in the Usage examples for Vue 3. Flexmonster usage in Nuxt and Vue 3 is similar.
Complete the following steps to integrate Flexmonster into a Nuxt project.
Skip this step if you already have a Nuxt project.
Сreate a Nuxt project by running the following commands in the console:
npx nuxi@latest init flexmonster_project
cd flexmonster_project
Flexmonster Vue wrapper must be used for integration with Nuxt. Run the following command to download and install the wrapper:
flexmonster add vue-flexmonster
This command downloads the vue-flexmonster wrapper to node_modules/ and adds it as a dependency to package.json.
To be integrated with Nuxt, Flexmonster must be used as a client-side plugin. To create and register this plugin, do the following:
Step 3.1. Create a plugins/ folder and open it.
Step 3.2. Inside the plugins/ folder, create a flexmonster.client.js file, where you need to import Flexmonster and define it as a Nuxt plugin:
import Pivot from "vue-flexmonster/vue3";
import "flexmonster/flexmonster.css";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component("Pivot", Pivot);
})
The plugin will load Flexmonster when the Vue application is created. If you are planning to also integrate with a 3rd-party charting library, import a Flexmonster connector for this library inside the plugin:
import Pivot from "vue-flexmonster/vue3";
import "flexmonster/flexmonster.css";
import "flexmonster/lib/flexmonster.amcharts";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component("Pivot", Pivot);
})
Step 3.3. Open the nuxt.config.ts file and register the plugin for Flexmonster by adding the following line of code:
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2024-04-03",
devtools: { enabled: true },
plugins: [{ src: "~/plugins/flexmonster.client.js", mode: "client" }]
})
Notice the mode: "client" option. This will ensure that Flexmonster is loaded only on the client side, which is necessary for Flexmonster to work.
Add Flexmonster to your page (e.g., app.vue):
<template>
<div>
<NuxtRouteAnnouncer />
<ClientOnly>
<Pivot/>
</ClientOnly>
</div>
</template>
Note The <Pivot> component must be added inside the <ClientOnly> component, so Flexmonster is rendered only on the client side.
Run your application from the console:
npm run dev
Open your project in the browser to see the result.
To shut down the project from the console, press Ctrl + C (Control + C on macOS).
If you run into any issues during the integration, visit our troubleshooting page.
Can't find your answer?
Visit the FAQ
Flexmonster Pivot Table & Charts is a JavaScript pivot table component for adding interactive reporting and data analysis to web applications. Users can summarize, filter, sort, and explore data in pivot tables and charts, drill into results, and export reports.
Flexmonster works in plain JavaScript and TypeScript projects. It also integrates with React, Next.js, Angular, Vue, Blazor, and other technologies. See all integration options.
Flexmonster supports JSON and CSV files, SQL databases, MongoDB, Elasticsearch, and Microsoft Analysis Services (SSAS). You can also connect other data sources through your own backend. See supported data sources.
Flexmonster offers licenses for internal corporate use, SaaS products, and OEM distribution. Pricing varies by license and plan. SaaS projects can also use the free SaaS Entry license during development. Learn more on the pricing page.
Yes. Flexmonster offers a 30-day free trial that lets you evaluate all its features. No credit card is required. The trial version has a watermark.
To get started with Flexmonster, follow our integration guide.