Skip to main content
Modelence modules support a 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 since modelence@0.15.0
  • createClientModule(...).getConfig() - available since modelence@0.15.0

Defining a Config Schema

Add a configSchema to your module definition. Each key becomes a configuration value namespaced under the module name:
src/server/payments/index.ts
Each config field requires three properties:

Config Types

The type field accepts one of five values:
Config values with type: 'secret' cannot have isPublic: true. Modelence will throw an error at startup if this rule is violated.

Reading Config Values

Server-side

Call getConfig 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

Use createClientModule 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
Only values marked 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 a configSchema, the configuration fields appear automatically in the Modelence Cloud dashboard:
  1. Go to cloud.modelence.com
  2. Select your environment
  3. Open the Application tab
  4. Find your module’s configuration section
  5. Set values and save
Changes sync to your running application automatically (within ~10 seconds).
Config values set in Modelence Cloud take precedence over defaults defined in your code. Environment variables take precedence over both.

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: