---
title: "SpeedCurve LUX · Nuxt Scripts"
description: "Use SpeedCurve LUX Real User Monitoring in your Nuxt app to measure performance experienced by real users, with automatic SPA navigation tracking."
canonical_url: "https://scripts.nuxt.com/scripts/speedcurve"
meta:
  "og:description": "Use SpeedCurve LUX Real User Monitoring in your Nuxt app to measure performance experienced by real users, with automatic SPA navigation tracking."
  "og:image": "https://scripts.nuxt.com/_og/s/o_672d6b86f51ed860.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "SpeedCurve LUX · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_672d6b86f51ed860.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Scripts**

# **SpeedCurve LUX**

[Copy for LLMs](https://scripts.nuxt.com/scripts/speedcurve.md)

[**SpeedCurve LUX**](https://www.speedcurve.com/features/performance-monitoring/) collects field performance data, including Core Web Vitals, custom timing marks, and JavaScript errors.

**SpeedCurve LUX**

[**View source **](https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/speedcurve.ts)

## Nuxt Config Setup

Add this to your `**nuxt.config.ts**` to load SpeedCurve LUX globally. Alternatively you can use the **useScriptSpeedCurve** composable for more control.

```
export default defineNuxtConfig({
  scripts: {
    registry: {
      speedcurve: {
        trigger: 'onNuxtReady',
      }
    }
  }
})
```

## useScriptSpeedCurve()

The `**useScriptSpeedCurve**` composable lets you have fine-grain control over when and how SpeedCurve LUX is loaded on your site.

```
const { proxy } = useScriptSpeedCurve()
```

Please follow the [**Registry Scripts **](https://scripts.nuxt.com/docs/guides/registry-scripts) guide to learn more about advanced usage.

## Example

Using SpeedCurve LUX in a component.

ConversionButton.vue

```
<script setup lang="ts">
const { proxy } = useScriptSpeedCurve()

// noop in development, ssr
// just works in production, client
function handleAction() {
  // use proxy methods here
}
</script>

<template>
  <div>
    <button @click="handleAction">
      Send Event
    </button>
  </div>
</template>
```

By default, the composable injects the LUX primer into `**<head>**` immediately and loads `**lux.js**` during Nuxt hydration.

## Setup

SpeedCurve LUX is opt-in. Register it in `**scripts.registry.speedcurve**` to resolve and inline the LUX primer at build time. Install the `**@speedcurve/lux**` peer dep alongside:

```bash
pnpm add -D @speedcurve/lux
```

nuxt.config.ts: composable-only (no global load)

```ts
export default defineNuxtConfig({
  modules: ['@nuxt/scripts'],
  scripts: {
    registry: {
      // Minimum registration: enables the composable per page.
      // Pass `id` here and you can omit it from each useScriptSpeedCurve() call.
      speedcurve: {},
    },
  },
})
```

nuxt.config.ts: auto-load globally

```ts
export default defineNuxtConfig({
  modules: ['@nuxt/scripts'],
  scripts: {
    registry: {
      speedcurve: { id: 'YOUR_SPEEDCURVE_ID', trigger: 'client' },
    },
  },
})
```

For SpeedCurve, the registry `**trigger**` above is the marker that generates a global composable call. `**useScriptSpeedCurve()**` hard-codes the effective trigger to `**client**`, so `**onNuxtReady**`, manual, consent, and custom promise triggers in registry or composable options do not change its load timing.

If `**speedcurve**` isn't registered, `**useScriptSpeedCurve**` builds with an empty primer fallback. If it's registered but `**@speedcurve/lux**` is missing, the build fails with an install hint. Pinning your own `**@speedcurve/lux**` version means you control when the primer snippet updates.

You can access the `**LUX**` object as a proxy directly, or await `**$script**` to get the loaded instance.

```ts
const { proxy } = useScriptSpeedCurve({ id: 'YOUR_ID' })
proxy.LUX.label = 'my-page'
```

## SPA navigation

Set `**spaMode: true**` to enable SpeedCurve's [**SPA tracking mode**](https://support.speedcurve.com/docs/single-page-applications). The composable wires Vue Router automatically:

- `**router.beforeEach**` calls `**LUX.startSoftNavigation()**`, closing the previous beacon and starting a new one
- `**nuxt.hook('page:finish')**` calls `**LUX.markLoadTime()**` after the next paint to set the END mark
- Canceled navigations tag the phantom beacon with `**addData('luxNavFailed', '1')**`

Install this in `**app.vue**`. Nuxt Scripts creates the automatic router hooks once per browser session, so the first auto-tracked call supplies their label and navigation options.

app.vue

```ts
useScriptSpeedCurve({
  id: 'YOUR_ID',
  spaMode: true,
  autoTrackSpaNavigations: true, // default when spaMode is true
})
```

To disable auto-wiring and instrument manually:

```ts
useScriptSpeedCurve({
  id: 'YOUR_ID',
  spaMode: true,
  autoTrackSpaNavigations: false,
})
// Then call LUX.startSoftNavigation() and LUX.markLoadTime() yourself
```

## Custom page labels

By default the composable uses `**String(to.name ?? to.path)**` as the page label for each navigation. Pass a function to `**label**` to override it:

```ts
useScriptSpeedCurve({
  id: 'YOUR_ID',
  spaMode: true,
  label: to => to.meta.title as string ?? to.path,
})
```

Set `**label: false**` to disable labeling entirely. Pass a plain string to set a static label (only meaningful without `**spaMode**`, since the router hook overwrites it on every navigation).

## CSP

Add these directives to your Content Security Policy:

```text
script-src  cdn.speedcurve.com;
img-src     lux.speedcurve.com;
connect-src lux.speedcurve.com beacon.speedcurve.com;
```

See SpeedCurve's [**LUX Content Security Policy guide**](https://support.speedcurve.com/docs/add-rum-to-your-csp) for the vendor's current directives.

`**id**``string`** required **

Your SpeedCurve customer ID.

`**spaMode**``boolean`

Enable SPA (single-page application) mode. When true, lux.js tracks soft navigations instead of full page loads.

`**autoTrackSpaNavigations**``boolean` = true (when spaMode is true)

Automatically wire Vue Router hooks for SPA tracking when spaMode is true. Set to false to instrument navigations manually.

`**label**``string | Function | false` = String(to.name ?? to.path)

Page label shown in the SpeedCurve dashboard. Accepts a static string, a function \`(to) => string | false\` for per-navigation labels, or \`false\` to disable labeling entirely. A callback returning \`false\` skips updating the label for that navigation.

`**samplerate**``number`

Sampling rate (0–100). Percentage of sessions that send beacons. Upstream spelling is lowercase — matches LUX UserConfig.

`**sendBeaconOnPageHidden**``boolean` = true

Send the beacon when the page is hidden (pagehide event).

`**trackErrors**``boolean` = true

Track JavaScript errors.

`**maxErrors**``number` = 5

Maximum number of errors to track per page view.

`**minMeasureTime**``number`

Minimum time (ms) before a beacon can be sent.

`**maxMeasureTime**``number` = 60000

Maximum time (ms) after which the beacon is sent regardless of load state.

`**newBeaconOnPageShow**``boolean`

Start a new beacon when the page becomes visible after being hidden.

`**trackHiddenPages**``boolean` = false

Track pages loaded in background tabs.

`**cookieDomain**``string`

Cookie domain for cross-subdomain session tracking.

## Example

Load SpeedCurve LUX through `**app.vue**` with SPA tracking enabled:

app.vue

```vue
<script setup lang="ts">
useScriptSpeedCurve({
  id: 'YOUR_SPEEDCURVE_ID',
  spaMode: true,
})
</script>
```

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/speedcurve.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/speedcurve.md)

[**Snapchat Pixel** Load Snapchat Pixel and opt in to automatic or manual page-view events.](https://scripts.nuxt.com/scripts/snapchat-pixel) [**Statable Analytics** Load the Statable tracker and record custom events.](https://scripts.nuxt.com/scripts/statable-analytics)

**On this page **

- [Setup](#setup)
- [SPA navigation](#spa-navigation)
- [Custom page labels](#custom-page-labels)
- [CSP](#csp)
- [Example](#example)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/speedcurve#webpage","@type":"WebPage","description":"Use SpeedCurve LUX Real User Monitoring in your Nuxt app to measure performance experienced by real users, with automatic SPA navigation tracking.","name":"SpeedCurve LUX","url":"https://scripts.nuxt.com/scripts/speedcurve","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/speedcurve#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/speedcurve"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/speedcurve#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"SpeedCurve LUX","item":"https://scripts.nuxt.com/scripts/speedcurve","position":3}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
