Adam L Barrett PRO
Adam L Barrett is a JavaScript and Front-End consultant, a contributor to open source, and avid bike-shedder.
Astro and the Island Architecture
Astro is a new kind of static site builder for the modern web
“...All of the other content is secondary to this information, and its inclusion in the HTML becomes a product decision. How vital is this bit of information to a user visiting the page? How important is that widget to the business model? A "buy now" button that directly relates to revenue should be easily prioritized over a site feedback survey button that relates to information gathering.”
Client Side
Rendering
Server Side
Rendering
"What the hell is that?"
"Better"
So SSR vs SPA becomes...
...and file based routing
---
import {format} from 'date-fns';
const builtAt: Date = new Date();
const builtAtFormatted = format(builtAt, 'MMMM dd, yyyy -- H:mm:ss.SSS');
---
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Astro Playground</title>
<style>
header {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
margin-top: 15vh;
font-family: Arial;
}
</style>
</head>
<body>
<header>
<img width="60" height="80" src="https://bestofjs.org/logos/astro.svg" alt="Astro logo">
<h1>Hello, Astro!</h1>
</header>
</body>
</html>
---
import { Markdown } from 'astro/components';
---
<Markdown>
# Markdown syntax is now supported! **Yay!**
</Markdown>
---
import { MovieList } from ':components/MovieList.jsx'
const response = await fetch('https://example.com/movies.json');
const data = await response.json();
---
<!-- Output the result to the page -->
<MovieList movies={data} />
...and use any framework
---
import { MovieList } from ':components/MovieList.jsx'
const response = await fetch('https://example.com/movies.json');
const data = await response.json();
---
<!-- Output the result to the page -->
<MovieList movies={data} />
---
import { MovieList } from ':components/MovieList.jsx'
const response = await fetch('https://example.com/movies.json');
const data = await response.json();
---
<!-- Output the result to the page -->
<MovieList client:load movies={data} />
<MyComponent client:load />
Start importing the component JS at page load. Hydrate the component when import completes
<MyComponent client:idle />
Start importing the component JS as soon as main thread is free. Hydrate the component when import completes.
<MyComponent client:visible />
Start importing the component JS as soon as the element enters the viewport. Hydrate the component when import completes. Useful for content lower down on the page
<MyComponent client:media={QUERY} />
Start importing the component JS as soon as the browser matches the given media query. Hydrate the component when import completes
<MyComponent client:only />
Start importing the component JS at page load and hydrate when the import completes, similar to client:load. The component will be skipped at build time
...Markdown, Code Blocks, RSS and more
Astro and the Island Architecture
By Adam L Barrett
Astro is the hot new static site builder for creating user-centric websites with “islands” of interactivity ...and the coolest part: You can even use React, Vue or Svelte components to build your site, or a combination of them, it doesn’t matter, it’s whatever you prefer. So come learn about the Islands Architecture, the features of Astro and how you can build full featured interactive websites
Adam L Barrett is a JavaScript and Front-End consultant, a contributor to open source, and avid bike-shedder.