> ## Documentation Index
> Fetch the complete documentation index at: https://docs.barekey.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Declared types

> Declared types control how Barekey parses values when the SDK resolves them.

Barekey stores values as strings, then parses them according to each variable's declared type.

That matters because `await barekey.get("KEY")` returns the parsed value, not just the raw string.

## Supported declared types

| Declared type | Returned SDK value |
| ------------- | ------------------ |
| `string`      | `string`           |
| `boolean`     | `boolean`          |
| `int64`       | `bigint`           |
| `float`       | `number`           |
| `date`        | `Date`             |
| `json`        | parsed JSON value  |

## Creating typed variables

Examples:

```bash theme={null}
barekey env new MAX_CONNECTIONS 100 --type int64
barekey env new FEATURE_ENABLED true --type boolean
barekey env new RELEASED_AT 2026-03-14T12:00:00.000Z --type date
barekey env new FEATURE_FLAGS '{"darkMode":true}' --type json
```

## Reading typed values with the SDK

```ts theme={null}
const maxConnections = await barekey.get("MAX_CONNECTIONS");
const featureEnabled = await barekey.get("FEATURE_ENABLED");
const releasedAt = await barekey.get("RELEASED_AT");
const featureFlags = await barekey.get("FEATURE_FLAGS");
```

Typical resolved value shapes:

* `MAX_CONNECTIONS` -> `100n`
* `FEATURE_ENABLED` -> `true`
* `RELEASED_AT` -> `new Date(...)`
* `FEATURE_FLAGS` -> parsed JSON

## Use `inspect()` for raw and parsed values together

```ts theme={null}
const result = await barekey.get("MAX_CONNECTIONS").inspect();

result.value; // bigint
result.rawValue; // "100"
result.declaredType; // "int64"
```

## Why declared types matter

Declared types make Barekey more useful because they:

* produce better generated SDK types
* reduce manual parsing in application code
* make CLI and API metadata easier to understand
* catch bad values earlier

## Recommendation

Always set `--type` when creating variables unless you truly want an unstructured string value.
