Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A counter component in Astro that logs each action to a history array.
---
import HistoryCounter from '../components/HistoryCounter.jsx';
---
<html>
<body>
<h1>Astro Counter History</h1>
<HistoryCounter />
</body>
</html>
// components/HistoryCounter.jsx
import { useState } from 'react';
export default function HistoryCounter() {
const [count, setCount] = useState(0);
const [history, setHistory] = useState([]);
const update = (action) => { setHistory([...history, action]); };
return (
<div>
<h2>Counter: {count}</h2>
<div>History: {history.join(', ')}</div>
<button onClick={() => { setCount(count + 1); update('Increment'); }}>+</button>
<button onClick={() => { setCount(count - 1); update('Decrement'); }}>-</button>
<button onClick={() => { setCount(0); update('Reset'); }}>Reset</button>
</div>
);
}Astro is a modern, content-focused web framework designed for building fast, optimized websites using a 'bring your own framework' philosophy and a server-first, zero-JS-by-default approach.
Origin & Creator
Created by Fred Schott and the Astro core team, originally launched in 2021 as an open-source initiative focused on performance-first web development.
Industrial Note
Astro excels in content-heavy sites like blogs, documentation, marketing pages, and any project prioritizing high performance and minimal client-side JavaScript.