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

# App Lifecycle

## Initialization

`fig.init` is the entry point for your app. `fig.init` is called once the `fig.js` runtime has loaded and configured the environment. Attempting to run `fig` commands before `fig.init` has been called will result in undefined behavior.

`$ echo "Hello, world."| fig your-app parameter --flag value`

```javascript
fig.init = (stdin, options) => {
    console.log(stdin)   // "Hello, world"
    console.log(options) // ["parameter", "--flag", "value"]
}
```

In this case, `stdin` would be `"Hello, world."`. and options will be a  list of the CLI flags. If your app is called with nothing piped in, `stdin` will be an empty string.

`fig.init` provides your app with any data from `stdin` that is passed to it as well as any flags/options, it is called with. The array of options can also be accessed with `fig.options`.
