Skip to content
infra-ts is early and moving fast.npm
infra-ts
Esc
navigateopen⌘Jpreview
On this page

Quickstart

Install infra-ts, create an infra.ts file, and preview the live reconciliation plan.

Install or run the CLI

Use the published package directly.

npm i -D infra-ts
# or run ad hoc
npx infra-ts --help

Create infra.ts

Declare resources as typed entity instances. Entity outputs are refs, so cross-provider wiring creates dependency edges automatically.

import { defineInfra } from "infra-ts";
import { NeonPostgres, NeonProject } from "infra-ts/neon";
import { VercelProject } from "infra-ts/vercel";

const project = new NeonProject({ name: "web", region: "aws-us-east-1" });
const db = new NeonPostgres({ name: "db", projectId: project.id });

export default defineInfra({
	entities: [
		project,
		db,
		new VercelProject({
			name: "web",
			env: { DATABASE_URL: db.env.databaseUrl },
		}),
	],
});

Authenticate providers

Provider packages read credentials from the environment or the CLIs you already use.

export NEON_API_KEY=...
export VERCEL_TOKEN=...

Preview and apply

plan reads live remote state and shows changes without mutating anything.

npx infra-ts plan
npx infra-ts apply
npx infra-ts status

Pull typed environment values

Entities can expose typed environment outputs. checkout pulls those values from live resources and writes .env.<env>.

npx infra-ts checkout --env local

In application code, parseEnv validates the process environment without network access:

import infra from "./infra";
import { parseEnv } from "infra-ts";

const env = parseEnv(infra);
env["db"].databaseUrl;

Run with resolved env

infra-ts run checks out env values in memory and runs a child command with those variables injected.

npx infra-ts run -- npm run dev

Was this page helpful?