https://github.com/hex-digital/nuxt-segment
Nuxt 3 module for Segment
https://github.com/hex-digital/nuxt-segment
Last synced: about 1 year ago
JSON representation
Nuxt 3 module for Segment
- Host: GitHub
- URL: https://github.com/hex-digital/nuxt-segment
- Owner: hex-digital
- License: mit
- Created: 2023-07-14T18:23:00.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-19T11:08:19.000Z (over 2 years ago)
- Last Synced: 2025-04-13T05:03:43.328Z (about 1 year ago)
- Language: TypeScript
- Size: 571 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Nuxt Plausible
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href]
> [Nuxt 3](https://nuxt.com) module to integrate [Segment analytics 2.0](https://github.com/segmentio/analytics-next/tree/master/packages/browser#readme).
- [✨ Release Notes](/CHANGELOG.md)
## Features
- 📯 Track events and page views manually with [composables](#composables)
- 📯 Optionally track page views automatically with the router integration
- 📂 [`.env` file support](#configuration)
- 🧺 Sensible default options
- 🦾 SSR-ready
## Quick Setup
1. Add `@hexdigital/nuxt-segment` dependency to your project
```bash
# Using pnpm
pnpm add -D @hexdigital/nuxt-segment
# Using yarn
yarn add --dev @hexdigital/nuxt-segment
# Using npm
npm install --save-dev @hexdigital/nuxt-segment
```
Add `@hexdigital/nuxt-segment` to the `modules` section of your Nuxt configuration:
```ts
// `nuxt.config.ts`
export default defineNuxtConfig({
modules: ['@hexdigital/nuxt-segment']
})
```
3. Add configuration in `nuxtConfig.segment` or in `nuxtConfig.runtimeConfig.public.segment`
This module supports two ways of configuration:
- Directly in key `segment` of the Nuxt config: `nuxtConfig.segment`
- In public runtimeConfig: `nuxtConfig.runtimeConfig.public.segment`
## Development
```bash
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release
```
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/my-module
[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/my-module
[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/my-module
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com