There is a first-class Astro integration for partytown.

Automatic Setup

Astro includes a CLI tool for adding integrations. Using the astro add command will automatically install Partytown and configure your project.

yarn astro add partytown # or npx astro add partytown

Partytown Script

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

<script type="text/partytown" src=""></script>

Note that the Astro Partytown integration already handles copying the library files to the correct location.