The Astro Global & Request Context
CONCEPTS:The Astro Global Object
Question Variations
- "How do you read a query parameter from the URL in an Astro component?"
- "Explain how to set a cookie in an Astro page."
- "What information is available in `Astro.request`?"
- "How do you perform a server-side redirect?"
Why This Is Asked
The Astro global is the primary way to interact with the web request. Understanding how to use it is essential for handling cookies, redirects, and dynamic routing logic.
Key Concepts
- Cookies: Reading and setting cookies for personalization or auth.
- URL API: Parsing search parameters or checking the current path.
- Request Headers: Detecting user-agent or language preferences.
- Redirects: Handling conditional logic (e.g., redirecting if not logged in).
Question Variations
- “How do you read a query parameter from the URL in an Astro component?”
- “Explain how to set a cookie in an Astro page.”
- “What information is available in
Astro.request?” - “How do you perform a server-side redirect?”