Accept configuration supplied through `cordis.yml`.
## Define the Config type
Export a `Config` type and a same-named Schemastery schema. Put defaults directly on the schema fields:
```ts
importtype{Context}from'cordis'
importSchemafrom'schemastery'
exportconstname='my-plugin'
exportinterfaceConfig{
greeting: string
maxRetries: number
verbose?: boolean
}
exportconstConfig: Schema<Config>=Schema.object({
greeting: Schema.string().default('Hello'),
maxRetries: Schema.number().default(3),
verbose: Schema.boolean().default(false),
})
exportfunctionapply(ctx: Context,config: Config){
console.log(config.greeting)// User value or schema default.
}
```
Configure it in `cordis.yml`:
```yaml
- name:'./src/my-plugin.ts'
config:
greeting:'Hi there'
maxRetries:5
```
When loading the plugin, Cordis uses the exported schema to validate configuration and fill defaults. Do not export a plain object as `Config`; it does not implement the Standard Schema interface required by Cordis.
A configuration edit hot-replaces the plugin: the framework unloads the old instance and loads a new one. Because registrations are effects and clean themselves up, replacement does not retain the old instance's registrations.
## Next steps
- [Plugins and lifecycle](../framework/) — understand the full plugin lifecycle
- [Services and dependencies](../framework/service.md) — provide a service to other plugins