configSchema that lets you define typed, named
configuration values. These values can be managed through Modelence Cloud and
accessed at runtime via typed accessors.
This is the recommended way to store settings like API keys, feature toggles,
default values, and any other configuration your module needs — without
hardcoding them or relying solely on environment variables.
Version Requirements
Configuration accessors in this guide require:Module.getConfig()- available sincemodelence@0.15.0createClientModule(...).getConfig()- available sincemodelence@0.15.0
Defining a Config Schema
Add aconfigSchema to your module definition. Each key becomes a configuration
value namespaced under the module name:
src/server/payments/index.ts
Config Types
Thetype field accepts one of five values:
Reading Config Values
Server-side
CallgetConfig directly on the module instance. The return type is inferred
automatically from the schema — no casts needed:
Module.getConfig() is available since modelence@0.15.0.
src/server/payments/index.ts
Client-side
UsecreateClientModule to create a typed accessor for a module’s public config values.
Pass the module type via import type — no server code is bundled on the client.
createClientModule(...).getConfig() is available since modelence@0.15.0.
src/client/payments.ts
src/components/Checkout.tsx
isPublic: true are available on the client. Private and
secret values are not sent to the client and will not appear as valid keys.
For typed query and mutation wrappers, see:
Managing Values in Modelence Cloud
Once your module defines aconfigSchema, the configuration fields appear
automatically in the Modelence Cloud dashboard:
- Go to cloud.modelence.com
- Select your environment
- Open the Application tab
- Find your module’s configuration section
- Set values and save
Examples
Storing a third-party API key
src/server/ai/index.ts
Feature toggle with a boolean config
src/server/notifications/index.ts
Exposing config to the client
src/server/app/index.ts
src/client/app.ts
src/components/Header.tsx
Type Reference
See the full API reference for config types:ConfigSchema— The schema object passed to a moduleConfigType— The union of allowed type valuesgetConfig(server) — Read config on the server (untyped, for dynamic keys)getConfig(client) — Read config on the client (untyped, for dynamic keys)