TypeScript / Nuxt

Instrument Nuxt server APIs.

Track Nuxt 3–4 Nitro server routes with private runtime credentials and no browser-side ingestion secret.

Nuxt 3–4Package v0.2.0Production ready
01

Quickstart

Install the public npm packages.

The framework adapter uses @apirelio/core for the common event contract and bounded asynchronous transport.

Terminalbash
npm install @apirelio/nuxt @apirelio/core
02

Framework integration

Enable automatic request tracking.

A Nitro server plugin captures matched server-route templates, response status, duration, sizes and explicitly allowed headers. Nuxt client navigation is not tracked.

nuxt.config.tstypescript
export default defineNuxtConfig({
  modules: ['@apirelio/nuxt'],
  apirelio: {
    service: 'billing-api',
    environment: 'production',
    metadataKeys: ['region'],
    includeRoutes: ['/api/**'],
    excludeRoutes: ['/api/health', '/api/internal/**'],
  },
})

// .env — private server runtime config
NUXT_APIRELIO_API_KEY=apr_live_xxxxxxxxx
03

Customer context

Attach the account and application.

Use stable external IDs from your authentication model. Customer names and plans can evolve without breaking analytics history.

server/middleware/customer.tstypescript
import { setApirelioContext } from '@apirelio/nuxt/runtime'

export default defineEventHandler((event) => {
  setApirelioContext(event, {
    customer: { id: 'cus_123', plan: 'growth' },
    application: { id: 'shopify', name: 'Shopify' },
    metadata: { region: 'eu' },
  })
})
04

Reliability

Flush safely during shutdown.

The Nitro close hook flushes pending events within a fixed timeout.

includeRoutes accepts exact paths or prefixes ending in /**. Explicit excludeRoutes always take precedence, keeping health checks, internal endpoints and presentation routes out of API analytics.

Non-blocking capture

The request only appends to a bounded in-memory queue. Network delivery, retry and batching happen outside the observed response path.

05

Data boundary

Operational signals only.

Request and response bodies, authorization values, cookies, query values, email addresses and client IP addresses are not captured. Custom scalar metadata must be explicitly allow-listed.

Server credentials only

Keep the ingestion key in server environment configuration. Do not expose it through client bundles or public runtime config.