Static vs Server-side Data Fetching in Astro
📖 Scenario: You are building a simple Astro website that shows a list of books. Some data will be fetched at build time (static), and some data will be fetched on each request (server-side).
🎯 Goal: Create an Astro component that fetches a static list of books at build time and also fetches the current date and time on each request using server-side data fetching.
📋 What You'll Learn
Create a static data array of books in the component
Create a server-side function to fetch the current date and time
Display the static books list in the page
Display the server-side fetched date and time in the page
💡 Why This Matters
🌍 Real World
Websites often need to show some data that never changes (static) and some data that updates every time a user visits (server-side).
💼 Career
Understanding static vs server-side data fetching is key for building fast, dynamic websites with frameworks like Astro.
Progress0 / 4 steps