@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
69 lines (36 loc) • 1.46 kB
Markdown
---
lang: en
title: 'API docs: core.application.onstart'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/core
permalink: /doc/en/lb4/apidocs.core.application.onstart.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/core](./core.md) > [Application](./core.application.md) > [onStart](./core.application.onstart.md)
## Application.onStart() method
Register a function to be called when the application starts.
This is a shortcut for adding a binding for a LifeCycleObserver implementing a `start()` method.
**Signature:**
```typescript
onStart(fn: () => ValueOrPromise<void>): Binding<LifeCycleObserver>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
fn
</td><td markdown="1">
() => [ValueOrPromise](./context.valueorpromise.md)<!-- --><void>
</td><td markdown="1">
The function to invoke, it can be synchronous (returning `void`<!-- -->) or asynchronous (returning `Promise<void>`<!-- -->).
</td></tr>
</tbody></table>
**Returns:**
[Binding](./context.binding.md)<!-- --><[LifeCycleObserver](./core.lifecycleobserver.md)<!-- -->>
The LifeCycleObserver binding created.