WhoBuilt

Astro, Island Technology in the Name of Optimization

Jul 4, 2024· 30 min· 323 views·Watch on YouTube

Speaker

Szymon Chmal of Bright Inventions presents Astro, a framework for content-driven websites, at a Callstack event in Wrocław.

Why Astro for content-driven sites

Chmal contrasts interactive applications with content-heavy sites, where frameworks such as Next.js can send JavaScript that a page may not need. Astro renders without client-side JavaScript by default, while allowing interactive features when needed. He sees it as a fit for blogs, news pages, shops, portfolios, and company sites.

Pages, components, and content

Astro uses file-based routing and supports pages written in HTML, JavaScript, Markdown, Astro components, or React. Astro components run their frontmatter JavaScript on the server, so API calls and database queries there are not sent to the browser. Content collections can validate metadata with Zod and generate TypeScript types; Astro also offers pagination and build-time image optimization.

Islands and rendering choices

Teams can add interactive islands using React, Solid, Svelte, Preact, or other integrated UI frameworks, and choose when to hydrate them with directives such as `client:load`, `client:idle`, and `client:visible`. Astro supports pre-rendered, server-rendered, and hybrid pages. API endpoints can keep third-party credentials on the server while providing data to UI components.

Transitions and choosing Astro

Astro's View Transitions integration can animate navigation between pages, while `transition:persist` preserves a client-only component's state across navigation. Chmal recommends considering Astro when limiting JavaScript matters, especially for content-focused sites, and notes that highly interactive applications may suit other tools better. In questions, he says Astro pages can coexist with a React app on a wildcard route, and that image processing happens at build time, which can add minutes for large image sets.

Takeaways

  • Use Astro for content-heavy pages where sending less JavaScript can improve access on slower devices.
  • Add client-side code only to the parts of a page that need interaction, and choose when each island hydrates.
  • Keep static and interactive routes in one Astro project, or mount a React app where a full client application is needed.
  • Validate content metadata with schemas so missing fields fail during the build.
  • Budget build time for local image processing; consider an image service when the image collection grows large.

Mentioned in this talk

Search inside this talk

What was claimed 13

  • metric
    Astra: 0 JavaScript by default
    “By default, you send basically nothing.”
    YouTube
    Unverified1 source· Talk
  • feature
    Astra: Sends no JavaScript by default; interactive components can be hydrated when needed.
    “in Astro, you can create websites with no JavaScript at all by default”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Astra integrates with Svelte
    “or Svelte to create Astro pages”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Astra integrates with Solid.js
    “Solid.js to create Astro pages”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Astra integrates with React
    “You can use React to create Astro pages”
    YouTube
    Unverified1 source· Talk
  • feature
    Astra: Uses a multipage application architecture.
    “Astro uses a multipage application architecture.”
    YouTube
    Unverified1 source· Talk
  • integrates with
    Astra integrates with Tailwind CSS
    “Astro integrates with many libraries”
    YouTube
    Unverified1 source· Talk
  • feature
    Astra: Content collections group content and support schema validation and generated TypeScript types.
    “there are content collections in Astro. Those allow us to group your content together.”
    YouTube
    Unverified1 source· Talk
Show all 13 facts

Related talks

Astro, Island Technology in the Name of Optimization, Szymon Chmal · WhoBuilt