Riven plugins read their configuration exclusively through theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/rivenmedia/riven-ts/llms.txt
Use this file to discover all available pages before exploring further.
PluginSettings utility — never directly from process.env. The framework strips all plugin-related environment variables from process.env before importing any plugin, ensuring no plugin can accidentally (or maliciously) read another plugin’s secrets. PluginSettings parses each plugin’s variables using a Zod schema, validates them at startup, then deep-freezes the result so settings cannot be mutated at runtime.
Defining a settings schema
Create a Zod object schema that describes every setting your plugin accepts. Add.describe() to each field — descriptions appear in generated documentation.
Environment variable naming convention
Each field in the schema maps to an environment variable following this pattern:<PREFIX> is the configPrefix registered for your plugin — typically derived from the package name in SCREAMING_SNAKE_CASE. For a package called @repo/plugin-my-service the prefix would be REPO_PLUGIN_MY_SERVICE.
Variable names are case-sensitive. The
fieldName portion must match the exact camelCase key in your Zod schema. Unrecognised keys are logged as warnings at startup.Reading settings in plugin code
Callsettings.get(YourSettingsSchema) anywhere you have access to a PluginSettings instance — inside hook handlers, validators, and the context() factory. The return type is fully inferred from the Zod schema.
The settings lifecycle
Scan environment variables
At startup
PluginSettings is constructed with the list of all registered plugin prefixes. It scans process.env, matches each variable against the pattern, and groups raw string values by prefix. All matched variables are deleted from process.env immediately so they cannot be read by later code.Parse with Zod (set)
The framework calls
settings.set(configPrefix, YourSchema) for each registered plugin. This calls schema.parse() on the raw string values for that prefix — applying coercions, defaults, and validations defined in the Zod schema. The parsed object is stored in an internal map keyed by the schema object itself.Plugin validator runs
Your plugin’s
validator({ dataSources, settings }) function is called. Throw a FatalValidationError here if the settings are permanently wrong (e.g. the API key is malformed or connectivity fails permanently).PluginSettings API reference
Returns the frozen, parsed settings object for the given schema. Throws
Error: Schema not found in settings map if set() was never called for this schema — which indicates a plugin registration bug.Parses all raw env values for
configPrefix using schema and stores the result. Called internally by the Riven plugin registrar — do not call this from plugin code.Freezes all settings objects and discards unused raw values. Called once after all plugins are registered. Subsequent calls to
set() throw.Registering the settings schema in the plugin
Pass your settings schema as thesettingsSchema field of your RivenPlugin export. The framework uses it to determine what prefix to call settings.set() with:
Exposing settings via GraphQL
Use the settings resolver pattern (described in detail in the Resolvers guide) to expose your plugin’s setting keys through GraphQL introspection. This allows the Riven UI to show which settings a plugin needs without the values ever leaving the server.Real-world example: TVDB plugin settings
The TVDB plugin uses a minimal settings schema with a singleapiKey field:
TvdbAPI the value is available as this.settings.apiKey:
FatalValidationError
ThrowFatalValidationError from your validator function when the settings are permanently wrong and retrying will not help: