/astro:astro-partytownfrom astro
Integrates third-party scripts (Google Analytics, GTM, Facebook Pixel) in Astro via Partytown web worker. Covers setup, forward config, custom events, conditional loading, cookie consent, and debugging.
Ships in astro. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Patterns for offloading third-party scripts to a web worker for better performance.
Third-party scripts (analytics, ads, chat widgets) block the main thread and slow page interactivity. Partytown runs them in a web worker, keeping the main thread free.
npx astro add partytown
// astro.config.mjs
import partytown from '@astrojs/partytown';
export default defineConfig({
integrations: [
partytown({
config: {
forward: ['dataLayer.push'],
},
}),
],
});
Scripts use type="text/partytown" and is:inline to run in the web worker. The forward array tells Partytown which functions to proxy from main thread to worker.
partytown({
config: {
forward: [
'dataLayer.push', // Google Analytics/GTM
'fbq', // Facebook Pixel
'gtag', // Google gtag
'_hsq.push', // HubSpot
],
},
}),
When integrating GA4, GTM, or Facebook Pixel, read
references/analytics-integration-examples.mdfor complete setup snippets with Partytown.
When implementing custom events, conditional loading, or cookie consent, read
references/analytics-integration-examples.mdfor React component events, production-only loading, and consent patterns.
When debugging Partytown issues (scripts not running, CORS errors), read
references/analytics-integration-examples.mdfor troubleshooting steps.
| Script Type | Forward Config | Notes |
|---|---|---|
| GA4 | dataLayer.push | Most common |
| GTM | dataLayer.push | Same as GA4 |
fbq | Single function | |
| HubSpot | _hsq.push | Array-based |
| Intercom | Intercom | Object-based |
| Custom | Add to forward | Any global function |
| Attribute | Purpose |
|---|---|
type="text/partytown" | Run in web worker |
is:inline | Don't bundle, keep inline |
define:vars={{ }} | Pass Astro vars to script |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
11 skills in this plugin
/astro-basicsACTIVATE when creating Astro components, layouts, pages, or setting up Astro project structure. ACTIVATE for 'Astro component', 'slot', 'layout', 'Astro.props', 'class:list'. Covers: component anatomy (frontmatter/template/style/script), layout pattern with slot, props patterns, scoped vs global styles, script patterns (build-time vs client-side), path aliases. DO NOT use for: content collections (see astro-content-collections), routing (see astro-routing), React islands (see astro-react)./astro-content-collectionsACTIVATE when working with Astro content collections, markdown/MDX files, YAML frontmatter, Zod schemas for content, or content-driven pages. ACTIVATE for 'getCollection', 'getEntry', 'defineCollection', 'content collection', 'content.config.ts'. Covers: collection schema definition with Zod, loader-based collections, querying/filtering collections, dynamic routes with getStaticPaths, YAML meta files, MDX with components, collection references. DO NOT use for: routing logic (see astro-routing), general Astro components (see astro-basics)./astro-envACTIVATE when working with environment variables, feature flags, or runtime configuration in Astro. ACTIVATE for 'import.meta.env', '.env', 'PUBLIC_', 'feature flag'. Covers: server vs client variables (PUBLIC_ prefix), feature flags pattern with centralized config, TypeScript env declarations, build-time vs runtime variables, Netlify/Vercel deployment vars. DO NOT use for: general Astro setup, content configuration.npx claudepluginhub fabiensalles/claude-marketplace --plugin astroOther plugins' skills for the same job