[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/core](../../README) / [index](../README) / withApp

# Function: withApp()

> **withApp**\<`T`\>(`app`, `fn`): `T`

Defined in: [application/currentApp.ts:71](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/application/currentApp.ts#L71)

Run `fn` with `app` as the current application for the duration of the call —
and everything it `await`s — overriding the process default within this scope.
The override is confined to the async context, so concurrent scopes never leak
into one another.

## Type Parameters

### T

`T`

## Parameters

### app

[`Application`](../classes/Application)

### fn

() => `T`

## Returns

`T`

## Example

```ts
// Run a migration against a second app's config without disturbing the default.
await withApp(secondApp, () => secondApp.container.make("db"));
```
