alepha@docs:~/docs/reference/primitives$
cat $parameter.md | pretty1 min read
#$parameter
#Import
typescript
1import { $parameter } from "alepha/api/parameters";
#Overview
Declares a named, schema-validated runtime parameter - configuration that
lives in the database, is editable from the admin UI, and is versioned with
rollback(). Read it with get(); every change records who made it.
#Options
| Option | Type | Required | Description |
|---|---|---|---|
name |
string |
No | Parameter name using dot notation for tree hierarchy |
description |
string |
No | Human-readable description of the parameter. |
schema |
T |
Yes | Zod schema defining the parameter structure. |
default |
Infer<T> |
Yes | Default value used when no parameter exists in database. |
migrate |
Object |
No | Optional migration function for schema changes |
#Examples
typescript
1class FeatureFlags { 2 checkout = $parameter({ 3 name: "checkout.flags", 4 schema: z.object({ oneClick: z.boolean() }), 5 default: { oneClick: false }, 6 }); 7 8 async isOneClickEnabled() { 9 return (await this.checkout.get()).oneClick;10 }11}