Context
The context object tells showwhat about the current request environment. Conditions evaluate against it.
Built-in properties
| Property | Type | Used by |
|---|---|---|
env | string | env condition |
at | string (ISO 8601) | startAt, endAt conditions |
Custom properties
The context accepts arbitrary properties with string, number, or boolean values. Use them with primitive condition types:
ts
const result = await showwhat({
keys: ["my_flag"],
context: {
env: "prod",
at: new Date().toISOString(),
region: "us-east-1",
tenant: "acme",
premium: true,
score: 85,
},
options: { data },
});
const flag = result["my_flag"];
if (!flag.error) {
console.log(flag.value);
}yaml
definitions:
my_flag:
variations:
- value: "custom"
conditions:
- type: string
key: tenant
op: eq
value: acme
- value: "default"When to pass at
Time-based conditions (startAt, endAt) check context.at. If you use time-based conditions, pass the current time:
ts
context: {
env: "prod",
at: new Date().toISOString(),
}If context.at is not provided, time-based conditions will not match.
Context vs deps
context holds evaluation data — values that conditions check against. For runtime utilities like hash functions, async fetchers, or lookup clients, use deps instead. See Dependency injection for details.