100 Astro resources for developers
Astro is designed for content-heavy applications where performance and type-safety are paramount. This resource guide focuses on the practical implementation of Astro's content collections, the efficient use of the island architecture for dynamic interactivity, and scaling strategies for programmatic SEO and edge deployment.
Content Collections and Type-Safe Schema Management
- 1
Zod Schema Validation
beginnerhighDefine strict frontmatter schemas in src/content/config.ts using Zod to ensure all markdown files contain required metadata like publishDate and author.
- 2
MDX Component Mapping
intermediatestandardUse the <Content components={{ h1: CustomHeading }}> syntax to override standard HTML elements with custom Astro or React components globally.
- 3
Discriminated Unions in Zod
advancedmediumImplement z.discriminatedUnion in collections to handle different types of content (e.g., 'video' vs 'article') within the same directory.
- 4
Automated Slug Generation
intermediatestandardOverride default slug generation by defining a custom 'slug' field in the Zod schema and using it in getStaticPaths for SEO-optimized URLs.
- 5
Reference API for Relations
intermediatehighUse the reference() function in Zod to create relationships between collections, such as linking an 'author' entry to a 'blog' entry.
- 6
Content Layer API (Experimental)
advancedhighUtilize the experimental content layer to fetch data from remote APIs or CMSs while maintaining the local Content Collection developer experience.
- 7
Markdown Image Resolution
beginnerstandardConfigure the image() helper in Zod schemas to automatically process and optimize local images referenced in markdown frontmatter.
- 8
Type-Safe Routing with getEntry
beginnerstandardUse the getEntry('collection', 'slug') function to fetch specific items with full TypeScript autocompletion for all frontmatter fields.
- 9
Custom Markdown Plugins
intermediatemediumInject remark-gfm or rehype-autolink-headings into astro.config.mjs to extend markdown functionality for technical documentation.
- 10
RSS Feed Generation
beginnerstandardImplement @astrojs/rss using content collection data to automatically generate valid XML feeds for blog subscribers.
Island Architecture and UI Optimization
- 1
Client:visible Directive
beginnerhighUse client:visible to delay hydration of heavy components (like complex charts) until they enter the user's viewport.
- 2
Client:idle for Low Priority
beginnerstandardApply client:idle to components like newsletter signups that don't need immediate interactivity, reducing initial TBT.
- 3
Nano Stores for State Management
intermediatehighUse Nano Stores to share state between multiple frameworks (e.g., React and Svelte) on the same page without a heavy runtime.
- 4
Svelte for Lightweight Islands
intermediatestandardIntegrate @astrojs/svelte for UI components that require minimal JavaScript bundle size compared to React or Vue.
- 5
Pagefind for Static Search
intermediatehighImplement Pagefind as a post-build step to provide full-text search capabilities without a server-side backend or heavy JS library.
- 6
Astro Image Component
beginnerhighReplace standard <img> tags with <Image /> from astro:assets to automate WebP conversion and layout shift prevention.
- 7
View Transitions API
intermediatemediumEnable the <ViewTransitions /> component in your layout to provide SPA-like navigation feel between static pages.
- 8
Persistent Islands
advancedmediumUse the transition:persist directive to keep a component state (like an audio player) alive across page navigations.
- 9
Prefetching Strategies
beginnerstandardConfigure the prefetch: true setting in astro.config.mjs to automatically load link data when users hover over internal links.
- 10
Client:only for Browser APIs
intermediatestandardUse client:only="react" for components that strictly require browser globals like window or document to prevent SSR errors.
Scaling for pSEO and Edge Deployment
- 1
Dynamic getStaticPaths
intermediatehighGenerate thousands of pages for programmatic SEO by mapping large JSON or CSV datasets to the getStaticPaths return array.
- 2
Cloudflare Pages Integration
beginnerhighDeploy Astro using the @astrojs/cloudflare adapter to leverage Edge Functions and fast static asset delivery.
- 3
Hybrid Rendering Mode
intermediatehighSet output: 'hybrid' in config to keep most pages static while enabling SSR for specific routes like auth or search results.
- 4
Edge Middleware for Geolocation
advancedmediumUse middleware.ts to detect user location and serve localized content or redirect to regional subdomains at the edge.
- 5
On-demand Incremental Static Regeneration
advancedhighConfigure Vercel or Netlify adapters to use On-demand Revalidation for updating specific pages without a full site rebuild.
- 6
External Data Fetching in Build
beginnerstandardFetch data from external APIs directly inside the frontmatter of .astro files to bake dynamic data into static HTML at build time.
- 7
Sitemap Module Configuration
beginnerstandardUse @astrojs/sitemap to automatically generate a sitemap.xml that includes all dynamic routes generated by getStaticPaths.
- 8
Environment Variable Validation
intermediatemediumUse the astro:env (experimental) or a custom Zod validation script to ensure required API keys are present during build.
- 9
Parallel Build Optimization
advancedmediumUtilize the build.concurrency setting in astro.config.mjs to speed up static generation for sites with 10,000+ pages.
- 10
Partytown for Third-Party Scripts
intermediatestandardOffload analytics and tracking scripts to a web worker using @astrojs/partytown to keep the main thread clear for user interactions.