# IUserSecretsManager

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

Defines an interface for managing user secrets with support for read and write operations.

## Definition

```typescript
interface IUserSecretsManager {
  readonly filePath: string;
  readonly isAvailable: boolean;
  getOrSetSecret(
      resourceBuilder: IResource,
      name: string,
      value: string): void;
  saveStateJson(
      json: string,
      cancellationToken?: cancellationToken): void;
  tryDeleteSecret(name: string): boolean;
  trySetSecret(
      name: string,
      value: string): boolean;
}
```

## Properties

- `filePath`: `string` `get` -- Gets the path to the user secrets file.
- `isAvailable`: `boolean` `get` -- Gets a value indicating whether user secrets are available.

## Methods

- [getOrSetSecret](/reference/api/typescript/aspire.hosting/iusersecretsmanager/getorsetsecret.md) -- `method` -- Gets a secret value if it exists in configuration, or sets it to the provided value if it does not.
    ```typescript
  getOrSetSecret(resourceBuilder: IResource, name: string, value: string): void
  ```
- [saveStateJson](/reference/api/typescript/aspire.hosting/iusersecretsmanager/savestatejson.md) -- `method` -- Saves state to user secrets from a JSON string.
    ```typescript
  saveStateJson(json: string, cancellationToken?: cancellationToken): void
  ```
- [tryDeleteSecret](/reference/api/typescript/aspire.hosting/iusersecretsmanager/trydeletesecret.md) -- `method` -- Attempts to delete a user secret value synchronously.
    ```typescript
  tryDeleteSecret(name: string): boolean
  ```
- [trySetSecret](/reference/api/typescript/aspire.hosting/iusersecretsmanager/trysetsecret.md) -- `method` -- Attempts to set a user secret value synchronously.
    ```typescript
  trySetSecret(name: string, value: string): boolean
  ```
