@webticks/nuxt
v0.2.1
Published
Nuxt 3 integration for WebTicks analytics
Readme
@webticks/nuxt
Nuxt 3 module for WebTicks analytics.
Installation
npm install @webticks/nuxtQuick Start
Configure the module in your Nuxt config:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@webticks/nuxt'],
runtimeConfig: {
public: {
webticks: {
serverUrl: 'https://your-api.com/track',
appId: 'your-app-id'
}
}
}
});Best Practices: Environment Variables
Nuxt 3 naturally supports environment variables via runtimeConfig. This is the recommended way to configure WebTicks.
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
public: {
webticks: {
// These can be overridden by NUXT_PUBLIC_WEBTICKS_SERVER_URL
// and NUXT_PUBLIC_WEBTICKS_APP_ID env variables
serverUrl: '', // Add process.env variable here''
appId: ''
}
}
}
});Configuration Options
| Option | Type | Description |
|--------|------|-------------|
| serverUrl | string | Recommended. URL to send analytics. Defaults to /api/track. |
| appId | string | Required. Your application ID. |
| debug | boolean | Optional. Enable console logging. Defaults to false. |
[!NOTE]
appIdandserverUrlare typically provided by the webticks-api project, which you can self-host. Alternatively, you can use any backend that implements the WebTicks ingestion API.
