﻿# 1Password Custody

> Keep your private keys in 1Password

[Custody](/docs/custody/)

## Install

Add 1Password to your Dotenvx installation.

Requires Dotenvx 3.0.

```console
$ dotenvx install --add 1password
```

Set up [1Password CLI](https://developer.1password.com/docs/cli/get-started/) (op version 2).

## Login

Sign in to 1Password CLI with an account that can create items in your vault. Follow the [1Password CLI setup guide](https://developer.1password.com/docs/cli/get-started/) for your sign-in method.

Sign in on each machine that needs access.

## Encrypt

From the project directory containing your .env file, encrypt and choose **more**, then **1Password** when prompted.

```console
$ dotenvx encrypt
```

Dotenvx encrypts your .env file and stores the private key in 1Password. Commit the encrypted .env file with your code.

For .env.production, add `-f .env.production`.

Already using .env.keys? Follow the [1Password migration guide](/docs/cli/1password-up/) to move your existing private key instead.

## Run

When you run your app, Dotenvx reads the private key through the signed-in 1Password CLI and loads your decrypted environment variables.

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

Run from the same project directory. Replace node index.js with your app’s start command.

That’s it! Your app now loads encrypted secrets with the private key stored in 1Password.

---

## 1Password Commands

- [1password up](/docs/cli/1password-up/)
- [1password down](/docs/cli/1password-down/)
- [1password push](/docs/cli/1password-push/)
- [1password pull](/docs/cli/1password-pull/)
- [1password list](/docs/cli/1password/list/)
- [1password show](/docs/cli/1password/show/)
