# `TypeError: Cannot read properties of undefined (reading '…')`

**Where it appears:** Browser or terminal

**What it means:** The code tried to read a field inside an item that is empty (`undefined`) instead of checking if it exists first.

## Likely causes

- Data from the database or an API hasn't loaded yet, or returned no matching record.
- A component prop was renamed or forgotten when rendering the component.

## Message for your agent

```text
I get `TypeError: Cannot read properties of undefined`. Find the line from the stack trace, handle the empty case safely, and add a test for when that value is missing.
```

**Prevention:** Always handle empty states (such as no items yet or a signed-out visitor) in every screen.

---
Source: [Agentic Makers](https://agenticmakers.app/en/help/errors/typeerror-cannot-read-properties-of-undefined) · License: CC BY 4.0
