# IResourceWithConnectionString

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.2.0`
- Kind: `interface`
- Source: [GitHub](https://github.com/microsoft/aspire)

## Definition

```typescript
interface IResourceWithConnectionString {
  getConnectionProperty(key: string): ReferenceExpression;
  onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise<void>): IResourceWithConnectionString;
  withConnectionProperty(
      name: string,
      value: ReferenceExpression): IResourceWithConnectionString;
  withConnectionPropertyValue(
      name: string,
      value: string): IResourceWithConnectionString;
}
```

## Methods

- [getConnectionProperty](/reference/api/typescript/aspire.hosting/iresourcewithconnectionstring/getconnectionproperty.md) -- `method` -- Gets a connection property by key
    ```typescript
  getConnectionProperty(key: string): ReferenceExpression
  ```
- [onConnectionStringAvailable](/reference/api/typescript/aspire.hosting/iresourcewithconnectionstring/onconnectionstringavailable.md) -- `method` -- Subscribes to the ConnectionStringAvailable event
    ```typescript
  onConnectionStringAvailable(callback: (arg: ConnectionStringAvailableEvent) => Promise<void>): IResourceWithConnectionString
  ```
- [withConnectionProperty](/reference/api/typescript/aspire.hosting/iresourcewithconnectionstring/withconnectionproperty.md) -- `method` -- Adds a connection property with a reference expression
    ```typescript
  withConnectionProperty(name: string, value: ReferenceExpression): IResourceWithConnectionString
  ```
- [withConnectionPropertyValue](/reference/api/typescript/aspire.hosting/iresourcewithconnectionstring/withconnectionpropertyvalue.md) -- `method` -- Adds a connection property with a string value
    ```typescript
  withConnectionPropertyValue(name: string, value: string): IResourceWithConnectionString
  ```
