> For the complete documentation index, see [llms.txt](https://docs.streamavatars.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/app-state-change.md).

# App State Change

```lua
function appStateChange(string_stateName)
    log('app is switching to state: ' .. string_stateName);
end

return function()
    addEvent('appState', 'appStateChange'); --subscribe to appState changes
    keepAlive();
end
```

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}
