Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,24 +267,51 @@ class BaseConfig:

@dataclasses.dataclass(kw_only=True, init=False)
class Config(BaseConfig):
"""The config defines runtime settings for the app.
"""Configuration class for Reflex applications.

By default, the config is defined in an `rxconfig.py` file in the root of the app.
The config defines runtime settings for your app including server ports, database connections,
frontend packages, and deployment settings.

By default, the config is defined in an `rxconfig.py` file in the root of your app:

```python
# rxconfig.py
import reflex as rx

config = rx.Config(
app_name="myapp",
api_url="http://localhost:8000",
# Server configuration
frontend_port=3000,
backend_port=8000,
# Database
db_url="postgresql://user:pass@localhost:5432/mydb",
# Additional frontend packages
frontend_packages=["react-icons"],
# CORS settings for production
cors_allowed_origins=["https://mydomain.com"],
)
```

Every config value can be overridden by an environment variable with the same name in uppercase and a REFLEX_ prefix.
For example, `db_url` can be overridden by setting the `REFLEX_DB_URL` environment variable.
## Environment Variable Overrides

Any config value can be overridden by setting an environment variable with the `REFLEX_`
prefix and the parameter name in uppercase:

```bash
REFLEX_DB_URL="postgresql://user:pass@localhost/db" reflex run
REFLEX_FRONTEND_PORT=3001 reflex run
```

## Key Configuration Areas

- **App Settings**: `app_name`, `loglevel`, `telemetry_enabled`
- **Server**: `frontend_port`, `backend_port`, `api_url`, `cors_allowed_origins`
- **Database**: `db_url`, `async_db_url`, `redis_url`
- **Frontend**: `frontend_packages`, `react_strict_mode`
- **State Management**: `state_manager_mode`, `state_auto_setters`
- **Plugins**: `plugins`, `disable_plugins`

See the [configuration](https://reflex.dev/docs/getting-started/configuration/) docs for more info.
See the [configuration docs](https://reflex.dev/docs/advanced-onboarding/configuration) for complete details on all available options.
"""

# Track whether the app name has already been validated for this Config instance.
Expand Down
Loading