API
Build-Time Parameters
Learn how to pass build-time configuration values into API extensions using Api.BuildParam and BuildParams.
- how to register a build-time parameter in
webiny.config.tsx - how to access it inside an API extension via dependency injection
Overview
BuildParams is the mechanism for passing configuration values — determined at build time — into API extensions. Values are registered in webiny.config.tsx using Api.BuildParam and embedded directly into the Lambda bundle during the build step.
This is distinct from Lambda environment variables, which are set at deploy time through infrastructure and are available via process.env. BuildParams are for values that come from your project configuration, not from AWS infrastructure.
Registering a Parameter
Declare parameters in webiny.config.tsx using Api.BuildParam:
The value can be a string, number, boolean, object, or array.
Accessing Parameters in an Extension
Inject BuildParams into any API extension class:
buildParams.get<T>(key) returns the value typed as T, or null if the key was not registered.
Deploying
After adding or changing a BuildParam, rebuild and redeploy the API: