# Components and Lifecycle Events In Lune, components are simplified compared to standard Vue. They are primarily functions that return a scope object. ## Function Components Reusable scope logic can be created with functions: ```js function Counter(props) { return { count: props.initialCount, inc() { this.count++; }, onMounted() { console.log(`I'm mounted!`); } }; } createApp({ Counter }).mount(); ``` ### Usage Use the function in `lu-scope` to instantiate the component: ```html

{{ count }}

{{ count }}

``` > [!NOTE] > Lune does **not** have automatic lifecycle hooks like `mounted()` or `setup()`. To run code when a component is mounted, define a method in your scope and wire it up manually using `@lune:mounted="methodName"`. See [Lifecycle Events](#lifecycle-events) for details. ## Components with Template If you want to reuse a piece of template, you can provide a special `$template` key on the scope object. The value can be an ID selector to a `