> For the complete documentation index, see [llms.txt](https://s19514tt.gitbook.io/vucript-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://s19514tt.gitbook.io/vucript-documentation/language-reference/lifecycle-methods.md).

# Lifecycle Methods

Vue Lifecycle Methods are methods which are called before events. There are 9 events that calls lifecycle methods.&#x20;

* onBeforeMount
* onMounted
* onBeforeUpdate
* onUpdated
* onBeforeUnmount
* onUnmounted
* onActivated
* onDeactivated
* onErrorCaptured

With vucript, you can write lifecycle functions like normal function.

```typescript
const lifecycleFunctionName = () => {
    //some actions here
};
```

### Example

```typescript
import { reactive } from 'Vucript'
const counter:reactive<number> = 0;
const onMounted = ()=>{
    add();
    console.log('mounted!');
}
function add(){
    counter++;
}
```

This code is compiled to

```typescript
import { defineComponent, ref, onMounted } from "vue";
export default defineComponent({
  setup() {
    const counter = ref<number>(0);
    const add = function () {
      counter.value++;
    };
    onMounted(() => {
      add();
      console.log("mounted!");
    });
    return { counter, add };
  },
});
```
