Skip to main content
This quickstart uses the actual shipped workflow:
  1. Install and log into the CLI.
  2. Run barekey init.
  3. Create a variable.
  4. Read it with @barekey/sdk/server.

Prerequisites

  • Node.js 18+ or Bun
  • a Barekey account

1. Install the CLI

Log in:
Check the session:

2. Run barekey init

In your project root, run:
This walks you through org, project, and stage selection and writes barekey.json for you. The generated file looks like this:
Barekey also accepts the aliases org and stage, but the canonical keys are:
  • organization
  • project
  • environment
Once this file exists, most CLI commands and SDK clients can resolve the target automatically.

3. Create a variable

Create a variable with an initial value:
If you omit arguments in an interactive terminal, Barekey can prompt you step by step instead. Read it back:
Update it later with env set:

4. Install the SDK

5. Read the variable in code

Create a shared client:
Because barekey.json is present, the client can resolve:
  • organization
  • project
  • environment
And because you already logged in with the CLI, the SDK can reuse the local CLI session for auth during local development. Read your variable:
If you want stronger startup guarantees, pass a schema directly:
await barekey.get("DATABASE_URL") returns the parsed value for the variable’s declared type. If you want metadata too, use inspect():

6. Generate SDK types

Run:
This updates generated types inside your installed @barekey/sdk package so known keys become typed in your editor. In development, you can keep it fresh:

7. Optional: pull to .env.local

If your local workflow still expects a dotenv file:
Or JSON:
Pulled files contain plaintext values. Add them to .gitignore.

What next

SDK guide

Full server SDK, public SDK, standalone mode, typegen, and config reference.

CLI guide

Full command reference with flags, examples, and output formats.

Local development

barekey.json, .env pull workflows, and standalone local reads.

Variable kinds

Understand secret and ab_roll.