# AddJavaScriptApp

- Module: [Aspire.Hosting.JavaScript](/reference/api/go/aspire.hosting.javascript.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: `DistributedApplicationBuilder`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Adds a JavaScript application resource to the distributed application using the specified app directory and run script.

## Remarks

If a Dockerfile does not exist in the application's directory, one will be generated
automatically when publishing. The method configures the resource with Node.js defaults and sets up npm
integration.

## Definition

```go
func (DistributedApplicationBuilder) AddJavaScriptApp(
    name string,
    appDirectory string,
    options ...*AddJavaScriptAppOptions,
) JavaScriptAppResource
```

## Parameters

- `name` (`string`) -- The unique name of the JavaScript application resource. Cannot be null or empty.
- `appDirectory` (`string`) -- The path to the directory containing the JavaScript application.
- `options` (`...*AddJavaScriptAppOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*AddJavaScriptAppOptions` argument.

- `RunScriptName` (`*string`) -- The name of the npm script to run when starting the application. Defaults to "dev". Cannot be null or empty.

## Returns

[`JavaScriptAppResource`](/reference/api/go/aspire.hosting.javascript/javascriptappresource.md) -- A resource builder for the newly added JavaScript application resource.

Returns a handle; failures surface later via `Err()`.

## Applies to

- `DistributedApplicationBuilder`
