# BunAppExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.Bun](/reference/api/csharp/communitytoolkit.aspire.hosting.bun.md)
- Type: [BunAppExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.bun/bunappextensions.md)
- Kind: `Methods`
- Members: `2`

Extension methods for adding a Bun app to a `Hosting.IDistributedApplicationBuilder`.

<a id="addbunapp"></a>
<a id="addbunapp-idistributedapplicationbuilder-string-string-string-bool"></a>

## AddBunApp(IDistributedApplicationBuilder, string, string?, string, bool)

- Name: `AddBunApp(IDistributedApplicationBuilder, string, string?, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<BunAppResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/0a6068734d939cdf93e8a6a0cab67cf1e5c76953/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs#L31-L43)

Adds a Bun app to the builder.

```csharp
public static class BunAppExtensions
{
    public static IResourceBuilder<BunAppResource> AddBunApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string? workingDirectory = null,
        string entryPoint = "index.ts",
        bool watch = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `workingDirectory` (`string?`) `optional`
  The working directory.
- `entryPoint` (`string`) `optional`
  The entry point, either a file or package.json script name.
- `watch` (`bool`) `optional`
  Whether to watch for changes.

## Returns

`IResourceBuilder<BunAppResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Capability ID: `CommunityToolkit.Aspire.Hosting.Bun/addBunApp`

<a id="withbunpackageinstallation"></a>
<a id="withbunpackageinstallation-iresourcebuilder-bunappresource-action-iresourcebuilder-buninstallerresource"></a>

## WithBunPackageInstallation(IResourceBuilder<BunAppResource>, Action<IResourceBuilder<BunInstallerResource>>)

- Name: `WithBunPackageInstallation(IResourceBuilder<BunAppResource>, Action<IResourceBuilder<BunInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<BunAppResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/0a6068734d939cdf93e8a6a0cab67cf1e5c76953/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs#L55)

Ensures the Bun packages are installed before the application starts using Bun as the package manager.

```csharp
public static class BunAppExtensions
{
    public static IResourceBuilder<BunAppResource> WithBunPackageInstallation(
        this IResourceBuilder<BunAppResource> resource,
        Action<IResourceBuilder<BunInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `resource` (`IResourceBuilder<BunAppResource>`)
  The Bun app resource.
- `configureInstaller` (`Action<IResourceBuilder<BunInstallerResource>>`) `optional`
  Configure the Bun installer resource.

## Returns

`IResourceBuilder<BunAppResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This overload is not available in polyglot AppHosts. Use [BunAppExtensions.WithBunPackageInstallation(IResourceBuilder<BunAppResource>, Action<IResourceBuilder<BunInstallerResource>>)](/reference/api/csharp/communitytoolkit.aspire.hosting.bun/bunappextensions/methods.md#withbunpackageinstallation-iresourcebuilder-bunappresource-action-iresourcebuilder-buninstallerresource) instead.

## ATS metadata

### Ignored by ATS

- Reason: Action<IResourceBuilder<BunInstallerResource>> is not ATS-compatible. Use the overload without configureInstaller instead.
