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 where only the theme can be toggled, count is static.
---
import DarkOnlyCounter from '../components/DarkOnlyCounter.jsx';
---
<html>
<body>
<h1>Astro Dark Mode Counter</h1>
<DarkOnlyCounter />
</body>
</html>
// components/DarkOnlyCounter.jsx
import { useState } from 'react';
export default function DarkOnlyCounter() {
const [isDark, setIsDark] = useState(false);
return (
<div className={isDark ? 'dark-theme' : 'light-theme'}>
<h2>Counter: 0</h2>
<button onClick={() => setIsDark(!isDark)}>Toggle Theme</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.