Astro is a Javascript web framework for creating fast, highly static, content-focused websites like marketing, publishing and portfolios sites, blogs and a few e-commerces.
Astro is a multi-page application (MPA) framework, unlike frameworks like React and Vue which are single-page application (SPA) frameworks
What are the differences between Single Page Application and Multi Page Application frameworks?
Single Page Application | Multi Page Application | |
---|---|---|
How it works | When user first navigate to a page , the entire application executable code is downloaded Only a single page is rendered on the client. Ajax calls can be made to get dynamic data after page is rendered | When user navigate to a page only that pages HTML is downloaded Pages are rendered on the server API calls are made from the server |
Performance | Slower first page load. Subsequent page navigation tend to be faster (no reload). | Offer much faster first page load time. Subsequent page navigation can be slower since there is no local rendering |
SEO | Great | Non-SEO friendly |
UX | Allows a seamless user experience | Bad UX for Highly interactive webapps / long lived sessions |
There are multiple page rendering strategies, but the most popular ones are, client side Rendering, server side rendering and static site generation
---
// Your component script here!
import Banner from '../components/Banner.astro';
import ReactPokemonComponent from '../components/ReactPokemonComponent.jsx';
const myFavoritePokemon = [/* ... */];
const { title } = Astro.props;
---
<!-- HTML comments supported! -->
{/* JS comment syntax is also valid! */}
<Banner />
<h1>Hello, world!</h1>
<!-- Use props and other variables from the component script: -->
<p>{title}</p>
<!-- Include other UI framework components with a `client:` directive to hydrate: -->
<ReactPokemonComponent client:visible />
<!-- Mix HTML with JavaScript expressions, similar to JSX: -->
<ul>
{myFavoritePokemon.map((data) => <li>{data.name}</li>)}
</ul>
<!-- Use a template directive to build class names from multiple strings or even objects! -->
<p class:list={["add", "dynamic", {classNames: true}]} />