Nuxt
There is a first-class Nuxt integration for partytown.
Install
Add @nuxtjs/partytown dependency to your project.
yarn add --dev @nuxtjs/partytown # or npm install --save-dev @nuxtjs/partytownConfigure
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.