# lace:init

Call methods or set properties when a component initializes.

```interlace-demo
InitDemo
```

## Syntax

```django
<div lace:init="method_name"></div>
<div lace:init="property = value"></div>
```

## Behavior

Executes after component mounts on initial page load. Useful for triggering side effects or setting initial state based on client-side data.

## Examples

Call Method on Init

```python
class Dashboard(Component):
    data: dict = {}

    def load_user_preferences(self):
        # Load preferences from localStorage via Alpine
        self.data = {"theme": "dark", "language": "en"}
```

```django
<div lace:init="load_user_preferences">
    Theme: {{ data.theme }}
</div>
```

Set Property on Init

```django
<div lace:init="initialized = true">
    {% if initialized %}
        <p>Component is ready</p>
    {% endif %}
</div>
```

Multiple Init Directives

```django
<div lace:init="fetch_data">
    <span lace:init="log_view">Content</span>
</div>
```
