Nuxt

There is a first-class Nuxt integration for partytown.

Install

Add @nuxtjs/partytown dependency to your project.

npm install --save-dev @nuxtjs/partytown
yarn add --dev @nuxtjs/partytown
pnpm install --save-dev @nuxtjs/partytown

Configure

Add @nuxtjs/partytown to the modules section of nuxt.config.ts. Use the partytown property for the configuration.

import { defineNuxtConfig } from 'nuxt';

export default defineNuxtConfig({
  modules: ['@nuxtjs/partytown'],
  partytown: {
    /* any partytown-specific configuration */
  },
});

Partytown Script

Add type: 'text/partytown' attribute to any scripts you want to be handled by partytown.

<template>
  <div>
    <Script type="text/partytown" src="https://example.com/analytics.js" />
  </div>
</template>

Note that the Nuxt Partytown module already handles copying the library files to the correct location.

Made with ❤️ by

© 2024 Builder.io, Inc.

Introducing Visual Copilot.

100% free. Supports all popular frameworks.

Try Visual Copilot