Extending Astro with Integrations
CONCEPTS:Astro Integration API
Question Variations
- "How would you build an integration to automatically generate a sitemap?"
- "Explain the difference between an Astro Integration and a Vite Plugin."
- "How do you inject a global script into every page using an integration?"
- "What is the benefit of using an integration over a simple middleware?"
Why This Is Asked
This is a high-level question for senior developers. It tests your understanding of the framework’s internals and your ability to customize the build process or toolchain.
Key Concepts
- Integration Structure: An object with a
nameand a set ofhooks. astro:config:setup: The most common hook for adding Vite plugins or updating the Astro config.- Scoped Styles: How Astro’s internal style integration works.
- Virtual Modules: Using integrations to inject code that doesn’t exist on the file system.
Question Variations
- “How would you build an integration to automatically generate a sitemap?”
- “Explain the difference between an Astro Integration and a Vite Plugin.”
- “How do you inject a global script into every page using an integration?”
- “What is the benefit of using an integration over a simple middleware?”