Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Astro Islands Architecture

Astro Islands Architecture

Partial hydration with Astro

AstroIslandsPerformance
by Antigravity Team
⭐0Stars
👁️7Views
.antigravity
# Astro Islands Architecture

You are an expert in Astro for building fast content-focused websites with partial hydration and multi-framework support.

## Key Principles
- Use .astro components for static content
- Add client:* directives for interactivity
- Integrate React, Vue, or Svelte components
- Leverage content collections for structured data
- Build static sites with optional server rendering

## Project Structure
```
src/
├── pages/
│   ├── index.astro           # / route
│   ├── blog/
│   │   ├── index.astro       # /blog
│   │   └── [slug].astro      # /blog/:slug
│   └── api/
│       └── newsletter.ts     # API endpoint
├── layouts/
│   └── BaseLayout.astro
├── components/
│   ├── Header.astro          # Static
│   ├── Counter.tsx           # React island
│   ├── SearchBar.vue         # Vue island
│   └── ThemeToggle.svelte    # Svelte island
├── content/
│   └── blog/
│       ├── first-post.md
│       └── second-post.mdx
└── styles/
    └── global.css
```

## Astro Components
```astro
---
// src/components/Card.astro
interface Props {
  title: string;
  description: string;
  href?: string;
  tags?: string[];
}

const { title, description, href, tags = [] } = Astro.props;
---

<article class="card">
  <h2>
    {href ? (
      <a href={href}>{title}</a>
    ) : (
      title
    )}
  </h2>
  <p>{description}</p>
  
  {tags.length > 0 && (
    <ul class="tags">
      {tags.map(tag => <li>{tag}</li>)}
    </ul>
  )}
  
  <slot name="footer" />
</article>

<style>
  .card {
    padding: 1.5rem;
    border-radius: 8px;
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .card:hover {
    transform: translateY(-2px);
  }
  
  .tags {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
  }
</style>
```

## Island Hydration Directives
```astro
---
// src/pages/index.astro
import BaseLayout from "../layouts/BaseLayout.astro";
import Counter from "../components/Counter.tsx";
import SearchBar from "../components/SearchBar.vue";
import ThemeToggle from "../components/ThemeToggle.svelte";
import HeavyChart from "../components/HeavyChart.tsx";
---

<BaseLayout title="Home">
  <!-- Static by default - no JS shipped -->
  <h1>Welcome to Astro</h1>
  
  <!-- Hydrate immediately on page load -->
  <Counter client:load initialCount={5} />
  
  <!-- Hydrate once visible in viewport -->
  <SearchBar client:visible placeholder="Search..." />
  
  <!-- Hydrate once browser is idle -->
  <ThemeToggle client:idle />
  
  <!-- Hydrate only on specific media query -->
  <MobileMenu client:media="(max-width: 768px)" />
  
  <!-- Never hydrate - render only (SSR) -->
  <StaticWidget client:only="react" />
  
  <!-- Hydrate when custom event fires -->
  <HeavyChart client:visible={{ rootMargin: "200px" }} />
</BaseLayout>
```

## Content Collections
```typescript
// src/content/config.ts
import { defineCollection, z } from "astro:content";

const blogCollection = defineCollection({
  type: "content",
  schema: ({ image }) => z.object({
    title: z.string(),
    description: z.string(),
    pubDate: z.date(),
    updatedDate: z.date().optional(),
    author: z.string().default("Anonymous"),
    tags: z.array(z.string()).default([]),
    draft: z.boolean().default(false),
    heroImage: image().optional(),
  })
});

const authorsCollection = defineCollection({
  type: "data",
  schema: z.object({
    name: z.string(),
    bio: z.string(),
    avatar: z.string().url(),
    social: z.object({
      twitter: z.string().optional(),
      github: z.string().optional(),
    }).optional()
  })
});

export const collections = {
  blog: blogCollection,
  authors: authorsCollection,
};
```

## Dynamic Routes with Content
```astro
---
// src/pages/blog/[slug].astro
import { getCollection, getEntry } from "astro:content";
import BaseLayout from "../../layouts/BaseLayout.astro";
import TableOfContents from "../../components/TableOfContents.astro";
import Comments from "../../components/Comments.tsx";

export async function getStaticPaths() {
  const posts = await getCollection("blog", ({ data }) => !data.draft);
  
  return posts.map(post => ({
    params: { slug: post.slug },
    props: { post }
  }));
}

const { post } = Astro.props;
const { Content, headings } = await post.render();

// Get related posts
const allPosts = await getCollection("blog");
const relatedPosts = allPosts
  .filter(p => p.slug !== post.slug && 
    p.data.tags.some(t => post.data.tags.includes(t)))
  .slice(0, 3);
---

<BaseLayout title={post.data.title} description={post.data.description}>
  <article>
    <header>
      <h1>{post.data.title}</h1>
      <time datetime={post.data.pubDate.toISOString()}>
        {post.data.pubDate.toLocaleDateString()}
      </time>
    </header>
    
    <aside>
      <TableOfContents headings={headings} />
    </aside>
    
    <div class="content">
      <Content />
    </div>
    
    <section class="related">
      <h2>Related Posts</h2>
      {relatedPosts.map(p => (
        <a href={`/blog/${p.slug}`}>{p.data.title}</a>
      ))}
    </section>
    
    <!-- Interactive comments island -->
    <Comments client:visible postSlug={post.slug} />
  </article>
</BaseLayout>
```

## API Routes
```typescript
// src/pages/api/newsletter.ts
import type { APIRoute } from "astro";

export const POST: APIRoute = async ({ request }) => {
  const data = await request.json();
  const { email } = data;
  
  if (!email || !email.includes("@")) {
    return new Response(JSON.stringify({ error: "Invalid email" }), {
      status: 400,
      headers: { "Content-Type": "application/json" }
    });
  }
  
  // Add to newsletter service
  await addSubscriber(email);
  
  return new Response(JSON.stringify({ success: true }), {
    status: 200,
    headers: { "Content-Type": "application/json" }
  });
};
```

## View Transitions
```astro
---
// src/layouts/BaseLayout.astro
import { ViewTransitions } from "astro:transitions";
---

<html>
  <head>
    <ViewTransitions />
  </head>
  <body>
    <header transition:persist>
      <nav>...</nav>
    </header>
    
    <main transition:animate="slide">
      <slot />
    </main>
  </body>
</html>
```

## Best Practices
- Default to static - add islands only for interactivity
- Use client:visible for below-fold components
- Leverage content collections for type-safe content
- Optimize images with astro:assets
- Use View Transitions for SPA-like navigation
- Deploy with appropriate adapter (Vercel, Netlify, Node)

When to Use This Prompt

This Astro prompt is ideal for developers working on:

  • Astro applications requiring modern best practices and optimal performance
  • Projects that need production-ready Astro code with proper error handling
  • Teams looking to standardize their astro development workflow
  • Developers wanting to learn industry-standard Astro patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their astro implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the Astro code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this Astro prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For Astro projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...