﻿# Dotenv.toml Quickstart

> Create your first Dotenv.toml

[Dotenv.toml](/docs/dotenv-toml/)

## Create

[Install Dotenvx](/docs/install/), then start with a `.env` file.

```dotenv
# .env
PORT=3000
DATABASE_URL="postgres://localhost/myapp"
```

Create a file named `Dotenv.toml` in your project root.

```toml
# Dotenv.toml
strict = true

[env.PORT]
type = "port"
required = true
storage = "plaintext"

[env.DATABASE_URL]
type = "url"
required = true
storage = "encrypted"
redacted = true
```

Both variables are required explicitly. `PORT` stays readable. `DATABASE_URL` is selected for encrypted storage and output redaction. `strict = true` stops your command when a value-validation rule fails.

## Encrypt

```console
$ dotenvx encrypt
```

Dotenvx encrypts `DATABASE_URL` and leaves `PORT` readable. Keep your private key separate from Git.

## Run

Dotenvx validates resolved values before running your app.

```console
$ dotenvx run -- node index.js
```

Replace `node index.js` with your app's command. Try `PORT=not-a-port` in `.env` to see strict validation stop startup. Change it back to `3000`.

The app receives the real database URL. Dotenvx redacts it in matching terminal output. Commit `Dotenv.toml` alongside the encrypted `.env` file.

[Read the full Dotenv.toml spec →](/docs/dotenv-toml/spec/)
