New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

cdk-typed-context

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdk-typed-context

latest
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

cdk-typed-context

TLDR: A package that adds strongly typed contexts to constructs.

Whenever I use cdk8s, I use getContext/setContext to manage a lot of global configuration and other contexts. Unfortunately, these context values are by default all untyped, so this package adds a lightweight wrapper around constructs' Node context methods to provide strongly typed contexts.

# or bun, yarn, pnpm, etc.
npm i cdk-typed-context
// env-context.ts
import { createContext } from "cdk-typed-context";

export const EnvContext = createContext<{ region: string; accountId: string }>("env", {
	errorOnMissing: "An environment has not been provided.",
});

// app.ts
EnvContext.set(this, {
	region: "us-east-1",
	accountId: "123456789012",
});

// some-child-construct.ts
const env = EnvContext.get(this);

new Deployment(this, "example-deployment", {
	containers: [
		{
			image: "some-image",
			envVariables: {
				REGION: { value: env.region },
				ACCOUNT_ID: { value: env.accountId },
			},
		},
	],
});

FAQs

Package last updated on 09 Feb 2026

Related posts