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 FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 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
Million.js React Optimization

Million.js React Optimization

Master Million.js virtual DOM optimization for Google Antigravity IDE high-performance React

Million.jsReactPerformanceOptimization
by Antigravity AI
⭐0Stars
.antigravity
# Million.js React Optimization for Google Antigravity IDE

Supercharge React performance with Million.js using Google Antigravity IDE. This guide covers compiler setup, block optimization, and directive usage patterns.

## Setup and Configuration

```typescript
// next.config.ts
import million from "million/compiler";

const nextConfig = { reactStrictMode: true };

export default million.next(nextConfig, {
  auto: {
    threshold: 0.05,
    skip: ["Header", "Footer", "*Provider*"],
  },
  rsc: true,
});
```

## Block Component Pattern

```typescript
// src/components/DataGrid.tsx
import { block, For } from "million/react";

interface DataRow {
  id: string;
  name: string;
  email: string;
  status: "active" | "inactive" | "pending";
}

const DataRowBlock = block(function DataRow({
  row,
  isSelected,
  onClick,
}: {
  row: DataRow;
  isSelected: boolean;
  onClick: () => void;
}) {
  return (
    <tr className={`data-row ${isSelected ? "selected" : ""}`} onClick={onClick}>
      <td><input type="checkbox" checked={isSelected} readOnly /></td>
      <td>{row.name}</td>
      <td>{row.email}</td>
      <td><span className={`status-badge status-${row.status}`}>{row.status}</span></td>
    </tr>
  );
});

export function DataGrid({ data, onRowClick, selectedIds = new Set() }: {
  data: DataRow[];
  onRowClick?: (row: DataRow) => void;
  selectedIds?: Set<string>;
}) {
  return (
    <table className="data-grid">
      <thead>
        <tr><th></th><th>Name</th><th>Email</th><th>Status</th></tr>
      </thead>
      <tbody>
        <For each={data}>
          {(row) => (
            <DataRowBlock
              key={row.id}
              row={row}
              isSelected={selectedIds.has(row.id)}
              onClick={() => onRowClick?.(row)}
            />
          )}
        </For>
      </tbody>
    </table>
  );
}
```

## Directive Optimization

```typescript
// src/components/ProductCard.tsx
"use million"; // Enable Million.js for this file

import Image from "next/image";
import Link from "next/link";

export function ProductCard({ product }: { product: Product }) {
  const formatPrice = (price: number) => {
    return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(price);
  };

  return (
    <Link href={`/products/${product.id}`} className="product-card">
      <div className="product-image">
        <Image src={product.image} alt={product.name} width={200} height={200} loading="lazy" />
        {!product.inStock && <span className="out-of-stock-badge">Out of Stock</span>}
      </div>
      <div className="product-info">
        <h3 className="product-name">{product.name}</h3>
        <div className="product-rating">
          {Array.from({ length: 5 }).map((_, i) => (
            <span key={i} className={`star ${i < product.rating ? "filled" : ""}`}>star</span>
          ))}
          <span className="review-count">({product.reviewCount})</span>
        </div>
        <p className="product-price">{formatPrice(product.price)}</p>
      </div>
    </Link>
  );
}
```

## Virtual List with For

```typescript
// src/components/VirtualList.tsx
import { For } from "million/react";
import { useVirtualizer } from "@tanstack/react-virtual";
import { useRef } from "react";

export function VirtualList({ items, estimateSize = 50 }: { items: Array<{ id: string; content: string }>; estimateSize?: number }) {
  const parentRef = useRef<HTMLDivElement>(null);
  const virtualizer = useVirtualizer({
    count: items.length,
    getScrollElement: () => parentRef.current,
    estimateSize: () => estimateSize,
    overscan: 5,
  });

  return (
    <div ref={parentRef} style={{ height: "400px", overflow: "auto" }}>
      <div style={{ height: `${virtualizer.getTotalSize()}px`, position: "relative" }}>
        <For each={virtualizer.getVirtualItems()}>
          {(virtualRow) => {
            const item = items[virtualRow.index];
            return (
              <div
                key={item.id}
                style={{
                  position: "absolute",
                  top: 0,
                  width: "100%",
                  height: `${virtualRow.size}px`,
                  transform: `translateY(${virtualRow.start}px)`,
                }}
              >
                {item.content}
              </div>
            );
          }}
        </For>
      </div>
    </div>
  );
}
```

## Best Practices for Google Antigravity IDE

When using Million.js with Google Antigravity, use auto mode for automatic optimization. Apply block() to frequently re-rendering components. Use For instead of map for lists. Skip components with complex state. Let Gemini 3 identify render bottlenecks and suggest Million.js optimizations.

Google Antigravity excels at analyzing React components and applying Million.js patterns.

When to Use This Prompt

This Million.js prompt is ideal for developers working on:

  • Million.js applications requiring modern best practices and optimal performance
  • Projects that need production-ready Million.js code with proper error handling
  • Teams looking to standardize their million.js development workflow
  • Developers wanting to learn industry-standard Million.js 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 million.js 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 Million.js 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 Million.js 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 Million.js projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...