During this video we'll learn about Astro components and how they work.
Astro components are the basic building blocks of Astro. Writing components should feel familiar to writing HTML (or Twig) and the transition to Astro components will feel familiar.
There are two parts to an Astro component:
In the Component Script, you can do anything you’d normally do in JavaScript or JavaScript framework code: import other code, fetch data, import data, set variables. It’s the place where you get the business of the component done.
The Component Template is where you write the markup that will render your component in the browser. You can write plain HTML and nothing else, and Astro will dutifully build your page using that component. You can also use JavaScript expressions (like mapping data you fetched in the Component Script section). Or, you might need to use Astro directives, like set:html
to handle data in a special way.
Astro Quick-Start Guide is made up of the following videos: