# 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`.

## 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/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs#L28-L40)

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`.

## 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/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs#L52-L68)

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`.
