#How to access data in astro
3 messages · Page 1 of 1 (latest)
Hi @acoustic spade. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
In Astro, you can access the data passed to a component through Astro.props. In your case, if you want to access the title prop in your MainLayout component, you can do it like this:
---
// This is the script part of your Astro component
const { title } = Astro.props;
---
<!-- This is the HTML part of your Astro component -->
<h1>{title}</h1>
In the script part of your Astro component, Astro.props is an object that contains all the props passed to the component. By destructuring Astro.props, you can directly access the title prop.