Skip to content
Logo

Nuxt

npm install @flarepanel/nuxt

Add the module and your client ID to nuxt.config.ts:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@flarepanel/nuxt'],
  openpanel: {
    clientId: 'YOUR_CLIENT_ID',
  },
});

Screen views, outgoing links and data-track attributes are tracked by default. Route changes count as screen views.

Track events

The useOpenPanel composable is imported for you:

<script setup lang="ts">
const op = useOpenPanel();
 
function upgrade() {
  op.track('upgrade_clicked', { plan: 'team' });
}
</script>
 
<template>
  <button @click="upgrade">Upgrade</button>
</template>

Identify a signed-in user once you know who they are:

const op = useOpenPanel();
op.identify({ profileId: user.id, email: user.email });

Options

OptionDefault
clientIdYour client ID
trackScreenViewstrueA screen view on every route change
trackOutgoingLinkstrueClicks on links to other sites
trackAttributestrueEvents from data-track attributes
trackHashChangesfalseAlso count #hash changes as screen views
disabledfalseTurn tracking off, for example in development
proxyfalseSend events through your app at /api/openpanel, so ad blockers do not stop them. Hosted service only
apiUrlhttps://api.flarepanel.devYour own API when self-hosting

All SDK options are accepted.

Self-hosting

Set apiUrl to your own API and leave proxy off: the proxy forwards to the hosted service.

openpanel: {
  clientId: 'YOUR_CLIENT_ID',
  apiUrl: 'https://api.example.com',
},