一键导入
add-integration
Guide complete integration setup including post-install configuration. Use when adding UI frameworks, adapters, or tooling to an Astro project.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide complete integration setup including post-install configuration. Use when adding UI frameworks, adapters, or tooling to an Astro project.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Set up and configure Astro content collections with the current Content Layer API and type-safe schemas. Use when creating blogs, docs, or any structured content.
Search and retrieve Astro documentation using the Astro Docs MCP. Use when answering questions about Astro APIs, configuration, integrations, or best practices.
Guide migration to Astro from other frameworks or between Astro versions. Use when converting Next.js, Nuxt, Gatsby projects or upgrading Astro.
Scaffold Astro components, pages, and layouts with best practices. Use when creating new .astro files or converting designs to components.
基于 SOC 职业分类
| name | add-integration |
| description | Guide complete integration setup including post-install configuration. Use when adding UI frameworks, adapters, or tooling to an Astro project. |
| Type | Examples | Key Considerations |
|---|---|---|
| UI Framework | React, Vue, Svelte, Solid, Preact | Client directives, hydration strategy |
| Styling | Tailwind, UnoCSS | CSS setup, config files |
| Adapter | Netlify, Vercel, Node, Cloudflare | Output mode, environment variables |
| Content | MDX, Markdoc | Content collections integration |
| Other | Sitemap, Partytown, DB | Feature-specific config |
Official integrations (support astro add):
npx astro add react
npx astro add tailwind
npx astro add netlify
Community integrations (manual install):
npm install astro-integration-name
Then add to astro.config.mjs:
import { defineConfig } from 'astro/config'
import integration from 'astro-integration-name'
export default defineConfig({
integrations: [integration()],
})
If the project is upgrading Astro itself, do not upgrade integrations in isolation:
This catches a large class of "the integration broke" issues that are actually runtime or version skew problems.
After npx astro add tailwind:
Create CSS file src/styles/global.css:
@import "tailwindcss";
Import in your layout:
---
import '../styles/global.css'
---
Optional: Configure in tailwind.config.mjs for customization
After adding a framework, understand client directives:
---
import Counter from './Counter.tsx'
---
<!-- No directive = server-rendered only, no JS -->
<Counter />
<!-- client:load = hydrate immediately (critical interactivity) -->
<Counter client:load />
<!-- client:idle = hydrate when browser is idle -->
<Counter client:idle />
<!-- client:visible = hydrate when scrolled into view -->
<Counter client:visible />
<!-- client:media = hydrate on media query match -->
<Counter client:media="(max-width: 768px)" />
<!-- client:only = skip server render entirely -->
<Counter client:only="react" />
Best practice: Start with client:visible or client:idle, use client:load only for above-the-fold critical UI.
Netlify (npx astro add netlify):
// astro.config.mjs
import { defineConfig } from 'astro/config'
import netlify from '@astrojs/netlify'
export default defineConfig({
output: 'server', // or 'hybrid'
adapter: netlify(),
})
Set environment variables in Netlify dashboard or netlify.toml.
Vercel (npx astro add vercel):
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel'
export default defineConfig({
output: 'server',
adapter: vercel({
webAnalytics: { enabled: true }, // Optional
}),
})
Cloudflare (npx astro add cloudflare):
import { defineConfig } from 'astro/config'
import cloudflare from '@astrojs/cloudflare'
export default defineConfig({
output: 'server',
adapter: cloudflare({
platformProxy: { enabled: true }, // For local dev
}),
})
After npx astro add mdx:
.mdx files work in src/pages/ and src/content/astro.config.mjs:import { defineConfig } from 'astro/config'
import mdx from '@astrojs/mdx'
export default defineConfig({
integrations: [mdx()],
markdown: {
remarkPlugins: [remarkPlugin],
rehypePlugins: [rehypePlugin],
},
})
Order can matter. General guidelines:
export default defineConfig({
integrations: [
// UI frameworks first
react(),
vue(),
// Then styling
tailwind(),
// Then content
mdx(),
// Then utilities
sitemap(),
],
})
| Issue | Solution |
|---|---|
| "Cannot find module" | Run npm install again, check package.json |
| Styles not loading | Check CSS import path, restart dev server |
| Hydration mismatch | Ensure server/client render same content |
| Build fails | Check adapter matches deployment platform |
| Build fails after Astro upgrade | Verify Node version, then upgrade official integrations/adapters alongside Astro |
| Integration not working | Verify it's in integrations[] array |