Nuxt
There is a first-class Nuxt integration for partytown.
Install
Add @nuxtjs/partytown dependency to your project.
yarn add @nuxtjs/partytown # or npm install @nuxtjs/partytownConfigure
Add @nuxtjs/partytown to the modules section of nuxt.config.ts. Use the partytown property for the configuration.
import { defineNuxtConfig } from 'nuxt3';
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.