Vue
This guide is for Vue 2 or Vue 3 applications and lets you choose the Vue version, package manager, bundler, and sourcemap setup that matches your app.
Laravel Mix is deprecated. We recommend Vite for new projects.
This guide covers every supported setup. Follow only the steps that match your project: conditional instructions start with a bold "If ..." line describing when they apply. Steps without such a line always apply. Install commands use
npm install. Swap that prefix for the project's own package manager:yarn add,pnpm add, orbun add. ReplacePROJECT PUBLIC KEYwith the project's public key. You can find it in the project settings on https://flareapp.io.
Step 1: Install the package using NPM, Yarn, pnpm, or Bun
If you don't upload sourcemaps to Flare:
npm install @flareapp/js @flareapp/vue
If you use Vite and upload sourcemaps to Flare:
npm install @flareapp/js @flareapp/vue @flareapp/vite
If you use Webpack and upload sourcemaps to Flare:
npm install @flareapp/js @flareapp/vue @flareapp/webpack
If you use Next.js and upload sourcemaps to Flare:
npm install @flareapp/js @flareapp/vue @flareapp/nextjs
Step 2: Register Flare & configure
Register the Flare Vue error handler in your app.js file:
If you upload sourcemaps to Flare:
In app.js:
import { createApp } from "vue";
import { flare } from "@flareapp/js";
import { flareVue } from "@flareapp/vue";
import App from "./App.vue";
// Only enable Flare in production, we don't want to waste your quota while you're developing:
if (process.env.NODE_ENV === 'production') {
flare.light();
}
const app = createApp(App);
flareVue(app);
app.mount('#app');
If you don't upload sourcemaps to Flare:
In app.js:
import { createApp } from "vue";
import { flare } from "@flareapp/js";
import { flareVue } from "@flareapp/vue";
import App from "./App.vue";
// Only enable Flare in production, we don't want to waste your quota while you're developing:
if (process.env.NODE_ENV === 'production') {
flare.light('PROJECT PUBLIC KEY');
}
const app = createApp(App);
flareVue(app);
app.mount('#app');
If you enable tracing:
Tracing shows you where time goes during a page load, a navigation, and the requests your page makes. Add this inside the same production check, after flare.light(). Read more in how tracing works and sampling.
In app.js:
flare.configure({
enableTracing: true,
// Sends 10% of traces. Raise it for more detail, lower it to save quota.
tracesSampleRate: 0.1,
});
If you use Vite and upload sourcemaps to Flare:
Configure Vite to upload sourcemaps to Flare:
In vite.config.js:
import { defineConfig } from 'vite';
import flareSourcemaps from '@flareapp/vite';
export default defineConfig({
plugins: [
flareSourcemaps({
apiKey: 'PROJECT PUBLIC KEY'
}),
],
});
If you use Webpack and upload sourcemaps to Flare:
Configure Webpack to upload sourcemaps to Flare:
In webpack.config.js:
const { FlareWebpackPlugin } = require("@flareapp/webpack");
module.exports = {
// ...
devtool: "source-map",
plugins: [ new FlareWebpackPlugin({ apiKey: "PROJECT PUBLIC KEY" }) ],
};
If you use Next.js and upload sourcemaps to Flare:
Wrap your Next.js config with withFlareSourcemaps in next.config.mjs:
In next.config.mjs:
import { withFlareSourcemaps } from '@flareapp/nextjs';
export default withFlareSourcemaps({
// your normal Next.js config
}, {
apiKey: 'PROJECT PUBLIC KEY',
});
Step 3: Connect your project key
If you upload sourcemaps to Flare:
When you install Flare's sourcemap build plugin, the build plugin injects your public key so flare.light() can run without an explicit key. Make sure you add the domains of your application in the project settings on Flare.
If you don't upload sourcemaps to Flare:
Pass your public key directly to flare.light('PROJECT PUBLIC KEY') and make sure you add the domains of your application in the project settings on Flare.
Step 4: Verify your setup
Add this code temporarily to verify everything is working:
In app.js:
flare.test();
If you use Vite and upload sourcemaps to Flare:
Run your Vite build command. You should see the following lines in the output:
@flareapp/vite: Uploading xx sourcemap(s) to Flare.
@flareapp/vite: Successfully uploaded all sourcemaps to Flare.
If you use Next.js and upload sourcemaps to Flare:
Run next build. You should see the following lines in the output:
@flareapp/webpack: Uploading 4 sourcemap(s) to Flare.
@flareapp/webpack: Successfully uploaded all sourcemaps to Flare.
Sourcemaps
If your Vue application is bundled for production, configure sourcemap uploads so Flare can display readable stack traces and code snippets. Start with the guide above for the common setup path, and use the resolving bundled code guide for advanced bundler configuration or manual upload options.
On this page