# JavaScriptHostingExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.JavaScript.Extensions](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions.md)
- Type: [JavaScriptHostingExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions.md)
- Kind: `Methods`
- Members: `15`

Provides extension methods for adding JavaScript applications to the distributed application builder.

## AddApp(IResourceBuilder<NxResource>, string, string?, Func<IResourceBuilder<NxAppResource>, IResourceBuilder<NxAppResource>>)

- Name: `AddApp(IResourceBuilder<NxResource>, string, string?, Func<IResourceBuilder<NxAppResource>, IResourceBuilder<NxAppResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxAppResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs#L71-L109)

Adds an individual app to an Nx workspace.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxAppResource> AddApp(
        this IResourceBuilder<NxResource> builder,
        string name,
        string? appName = null,
        Func<IResourceBuilder<NxAppResource>, IResourceBuilder<NxAppResource>>? configure = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<NxResource>`)
  The Nx workspace resource builder.
- `name` (`string`)
  The name of the app resource.
- `appName` (`string?`) `optional`
  The Nx app name to run. If not specified, uses the `name`.
- `configure` (`Func<IResourceBuilder<NxAppResource>, IResourceBuilder<NxAppResource>>`) `optional`
  A function to configure the app resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.AddNxWorkspaceApp](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddApp(IResourceBuilder<TurborepoResource>, string, string?, Func<IResourceBuilder<TurborepoAppResource>, IResourceBuilder<TurborepoAppResource>>)

- Name: `AddApp(IResourceBuilder<TurborepoResource>, string, string?, Func<IResourceBuilder<TurborepoAppResource>, IResourceBuilder<TurborepoAppResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoAppResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs#L128-L166)

Adds an individual app to a Turborepo workspace.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoAppResource> AddApp(
        this IResourceBuilder<TurborepoResource> builder,
        string name,
        string? filter = null,
        Func<IResourceBuilder<TurborepoAppResource>, IResourceBuilder<TurborepoAppResource>>? configure = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TurborepoResource>`)
  The Turborepo workspace resource builder.
- `name` (`string`)
  The name of the app resource.
- `filter` (`string?`) `optional`
  The Turborepo filter to use. If not specified, uses the `name`.
- `configure` (`Func<IResourceBuilder<TurborepoAppResource>, IResourceBuilder<TurborepoAppResource>>`) `optional`
  A function to configure the app resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.AddTurborepoWorkspaceApp](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddNxApp(IDistributedApplicationBuilder, string, string?)

- Name: `AddNxApp(IDistributedApplicationBuilder, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs#L25-L34)

Adds an Nx monorepo workspace to the distributed application builder.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxResource> AddNxApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string? workingDirectory = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the Nx workspace resource.
- `workingDirectory` (`string?`) `optional`
  The working directory of the Nx workspace. If not specified, it will be set to a path that is a sibling of the AppHost directory using the `name` as the folder.

## Returns

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

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddTurborepoApp(IDistributedApplicationBuilder, string, string?)

- Name: `AddTurborepoApp(IDistributedApplicationBuilder, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs#L47-L56)

Adds a Turborepo monorepo workspace to the distributed application builder.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoResource> AddTurborepoApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string? workingDirectory = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the Turborepo workspace resource.
- `workingDirectory` (`string?`) `optional`
  The working directory of the Turborepo workspace. If not specified, it will be set to a path that is a sibling of the AppHost directory using the `name` as the folder.

## Returns

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

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithBun(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithBun(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Nx workspace to use bun as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxResource> WithBun(
        this IResourceBuilder<NxResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<NxResource>`)
  The Nx workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithNxBun](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithBun(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithBun(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Turborepo workspace to use bun as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoResource> WithBun(
        this IResourceBuilder<TurborepoResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TurborepoResource>`)
  The Turborepo workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithTurborepoBun](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithMappedEndpointPort(IResourceBuilder<TResource>, string?)

- Name: `WithMappedEndpointPort(IResourceBuilder<TResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs#L259-L278)

Maps the endpoint port for the `JavaScript.JavaScriptAppResource` to the appropriate command line argument.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TResource> WithMappedEndpointPort<TResource>(
        this IResourceBuilder<TResource> builder,
        string? endpointName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TResource>`)
  The Node.js app resource.
- `endpointName` (`string?`) `optional`
  The name of the endpoint to map. If not specified, it will use the first HTTP or HTTPS endpoint found.

## Returns

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

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithNpm(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithNpm(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Nx workspace to use npm as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxResource> WithNpm(
        this IResourceBuilder<NxResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<NxResource>`)
  The Nx workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithNxNpm](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithNpm(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithNpm(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Turborepo workspace to use npm as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoResource> WithNpm(
        this IResourceBuilder<TurborepoResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TurborepoResource>`)
  The Turborepo workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithTurborepoNpm](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithPackageManagerLaunch(IResourceBuilder<NxResource>, string?)

- Name: `WithPackageManagerLaunch(IResourceBuilder<NxResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Nx workspace to use the specified JavaScript package manager when starting apps.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxResource> WithPackageManagerLaunch(
        this IResourceBuilder<NxResource> builder,
        string? packageManager = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<NxResource>`)
  The Nx workspace resource builder.
- `packageManager` (`string?`) `optional`
  The package manager to use. If none is provided it will attempt to use the installer annotation's resource command.

## Returns

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

## Exceptions

- `InvalidOperationException` -- Thrown if the Nx workspace is already configured to use a different package manager.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithPackageManagerLaunch(IResourceBuilder<TurborepoResource>, string?)

- Name: `WithPackageManagerLaunch(IResourceBuilder<TurborepoResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Turborepo workspace to use the specified JavaScript package manager when starting apps.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoResource> WithPackageManagerLaunch(
        this IResourceBuilder<TurborepoResource> builder,
        string? packageManager = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TurborepoResource>`)
  The Turborepo workspace resource builder.
- `packageManager` (`string?`) `optional`
  The package manager to use. If none is provided it will attempt to use the installer annotation's resource command.

## Returns

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

## Exceptions

- `InvalidOperationException` -- Thrown if the Turborepo workspace is already configured to use a different package manager.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithPnpm(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithPnpm(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Nx workspace to use pnpm as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxResource> WithPnpm(
        this IResourceBuilder<NxResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<NxResource>`)
  The Nx workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithNxPnpm](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithPnpm(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithPnpm(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Turborepo workspace to use pnpm as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoResource> WithPnpm(
        this IResourceBuilder<TurborepoResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TurborepoResource>`)
  The Turborepo workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithTurborepoPnpm](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithYarn(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithYarn(IResourceBuilder<NxResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<NxResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Nx workspace to use yarn as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<NxResource> WithYarn(
        this IResourceBuilder<NxResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<NxResource>`)
  The Nx workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithNxYarn](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithYarn(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)

- Name: `WithYarn(IResourceBuilder<TurborepoResource>, bool, Action<IResourceBuilder<JavaScriptInstallerResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TurborepoResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs)

Configures the Turborepo workspace to use yarn as the package manager and optionally installs packages before apps start.

```csharp
public static class JavaScriptHostingExtensions
{
    public static IResourceBuilder<TurborepoResource> WithYarn(
        this IResourceBuilder<TurborepoResource> builder,
        bool install = false,
        Action<IResourceBuilder<JavaScriptInstallerResource>>? configureInstaller = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TurborepoResource>`)
  The Turborepo workspace resource builder.
- `install` (`bool`) `optional`
  When true, automatically installs packages before apps start. When false (default), only sets the package manager annotation without creating an installer resource.
- `configureInstaller` (`Action<IResourceBuilder<JavaScriptInstallerResource>>`) `optional`
  A function to configure the installer resource builder.

## Returns

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

## Remarks

This overload is not available in polyglot app hosts. Use [JavaScriptHostingExtensions.WithTurborepoYarn](/reference/api/csharp/communitytoolkit.aspire.hosting.javascript.extensions/javascripthostingextensions/methods.md) instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
