Astro throws “Invalid component arguments” when you call an Astro component as a function, for example Card() or {items.map(Card)}, instead of rendering it as a tag. Astro components are not plain functions you can call with props; render them with JSX-like syntax, <Card {...item} />, and the error goes away.
Key Takeaways
- Astro components must be rendered as tags:
<Card />, neverCard().{items.map(Card)}passes(item, index, array)to the component and fails.- Write
{items.map((item) => <Card {...item} />)}instead.- A component chosen at runtime still renders as a tag:
<Component />from a variable.- React-style “call the component” habits are the usual source of this error.
The error
Invalid component arguments.
Invalid arguments passed to <Card> component.
Hint: Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`.
Why it happens
The compiled form of an .astro file is a factory that Astro’s renderer calls with three internal arguments: the render context, the props object and the slots. When you call it yourself, it receives the wrong arguments, and Astro checks for exactly that before rendering. The most common version is passing the component straight to map():
---
// src/pages/index.astro (fails)
import Card from '../components/Card.astro';
const items = [
{ title: 'Design', text: 'Brand and web design.' },
{ title: 'Build', text: 'Fast static sites in Astro.' },
];
---
<div class="grid">{items.map(Card)}</div>
map() calls Card(item, index, array), which is not what the renderer expects. Depending on the values, you get this error or a less obvious one later in rendering; the fix is the same.
Fix: render it as a tag
---
// src/pages/index.astro
import Card from '../components/Card.astro';
const items = [
{ title: 'Design', text: 'Brand and web design.' },
{ title: 'Build', text: 'Fast static sites in Astro.' },
];
---
<div class="grid">
{items.map((item) => <Card title={item.title} text={item.text} />)}
</div>
Spreading also works: <Card {...item} />. Inside the component, the values arrive on Astro.props:
---
// src/components/Card.astro
interface Props { title: string; text: string }
const { title, text } = Astro.props;
---
<article><h3>{title}</h3><p>{text}</p></article>
Fix: dynamic components
If you pick the component at runtime, assign it to a capitalised variable and render that as a tag:
---
// src/components/Section.astro
import Hero from './Hero.astro';
import Banner from './Banner.astro';
const { variant = 'hero' } = Astro.props;
const Component = variant === 'hero' ? Hero : Banner;
---
<Component title="Welcome" />
The variable name must start with a capital letter so the compiler treats it as a component, not an HTML element.
Getting HTML as a string
If you called the component because you wanted its HTML (for an RSS feed or an email), use the Container API rather than a function call. Our Container API guide shows renderToString(). For the basics of props and slots, see the Astro components guide and the template syntax cheatsheet. The pages docs and the official template expressions reference cover the syntax. If you are editing a theme’s section components, the Astro themes catalog shows how each theme’s pages compose them.
FAQ
Can I call an Astro component like a function?
No. Astro components are rendered by Astro’s renderer, which passes internal arguments. Always render them as tags in a template.
How do I loop over components in Astro?
Use map() with an arrow function that returns a tag: {items.map((item) => <Card {...item} />)}. Add a wrapper element if you need one around each item.
Why does this work in React but not Astro?
React function components are plain functions that accept props, so calling them sometimes appears to work. Astro components are compiled differently and must always go through the renderer.