> For AI agents: the complete documentation index is at [llms.txt](https://reflex.dev/docs/llms.txt). Markdown versions are available by appending `.md` or sending `Accept: text/markdown`.

# Config

`reflex_base.config.Config`

Configuration class for Reflex applications.

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",
    # 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"],
)
```

## 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 docs](https://reflex.dev/docs/advanced-onboarding/configuration) for complete details on all available options.

## Fields

| Prop | Description |
| --- | --- |
| `app_name: str` |  |
| `app_module_import: str \| None` |  |
| `loglevel: LogLevel` |  |
| `frontend_port: int \| None` |  |
| `frontend_path: str` |  |
| `backend_port: int \| None` |  |
| `backend_path: str` |  |
| `api_url: str` |  |
| `deploy_url: str \| None` |  |
| `backend_host: str` |  |
| `db_url: str \| None` |  |
| `async_db_url: str \| None` |  |
| `redis_url: str \| None` |  |
| `telemetry_enabled: bool` |  |
| `bun_path: Path` |  |
| `static_page_generation_timeout: int` |  |
| `cors_allowed_origins: collections.abc.Sequence[str]` |  |
| `vite_allowed_hosts: bool \| list[str]` |  |
| `react_strict_mode: bool` |  |
| `frontend_packages: list[str]` |  |
| `state_manager_mode: StateManagerMode` |  |
| `redis_lock_expiration: int` |  |
| `redis_lock_warning_threshold: int` |  |
| `redis_token_expiration: int` |  |
| `env_file: str \| None` |  |
| `state_auto_setters: bool` |  |
| `show_built_with_reflex: bool \| None` |  |
| `is_reflex_cloud: bool` |  |
| `extra_overlay_function: str \| None` |  |
| `plugins: list[reflex_base.plugins.base.Plugin]` |  |
| `disable_plugins: list[type[reflex_base.plugins.base.Plugin]]` |  |
| `transport: typing.Literal['websocket', 'polling']` |  |
| `app_name: str` | The name of the app (should match the name of the app directory). |
| `app_module_import: str \| None` | The path to the app module. |
| `loglevel: LogLevel` | The log level to use. |
| `frontend_port: int \| None` | The port to run the frontend on. NOTE: When running in dev mode, the next available port will be used if this is taken. |
| `frontend_path: str` | The path to run the frontend on. For example, "/app" will run the frontend on http://localhost:3000/app |
| `backend_port: int \| None` | The port to run the backend on. NOTE: When running in dev mode, the next available port will be used if this is taken. |
| `backend_path: str` | The path prefix for backend routes. For example, "/api" mounts the event websocket, /ping, /_upload, /_health, and /_all_routes under /api, and is automatically included in URLs baked into the frontend. Changing this requires a full `reflex run` restart — routes are registered at startup. |
| `api_url: str` | The backend url the frontend will connect to. This must be updated if the backend is hosted elsewhere, or in production. |
| `deploy_url: str \| None` | The url the frontend will be hosted on. |
| `backend_host: str` | The url the backend will be hosted on. |
| `db_url: str \| None` | The database url used by rx.Model. |
| `async_db_url: str \| None` | The async database url used by rx.Model. |
| `redis_url: str \| None` | The redis url. |
| `telemetry_enabled: bool` | Telemetry opt-in. |
| `bun_path: Path` | The bun path. |
| `static_page_generation_timeout: int` | Timeout to do a production build of a frontend page. |
| `cors_allowed_origins: collections.abc.Sequence[str]` | Comma separated list of origins that are allowed to connect to the backend API. |
| `vite_allowed_hosts: bool \| list[str]` | Allowed hosts for the Vite dev server. Set to True to allow all hosts, or provide a list of hostnames (e.g. ["myservice.local"]) to allow specific ones. Prevents 403 errors in Docker, Codespaces, reverse proxies, etc. |
| `react_strict_mode: bool` | Whether to use React strict mode. |
| `frontend_packages: list[str]` | Additional frontend packages to install. |
| `state_manager_mode: StateManagerMode` | Indicate which type of state manager to use. |
| `redis_lock_expiration: int` | Maximum expiration lock time for redis state manager. |
| `redis_lock_warning_threshold: int` | Maximum lock time before warning for redis state manager. |
| `redis_token_expiration: int` | Token expiration time for redis state manager. |
| `env_file: str \| None` | Path to file containing key-values pairs to override in the environment; Dotenv format. |
| `state_auto_setters: bool` | Whether to automatically create setters for state base vars. |
| `show_built_with_reflex: bool \| None` | Whether to display the sticky "Built with Reflex" badge on all pages. |
| `is_reflex_cloud: bool` | Whether the app is running in the reflex cloud environment. |
| `extra_overlay_function: str \| None` | Extra overlay function to run after the app is built. Formatted such that `from path_0.path_1... import path[-1]`, and calling it with no arguments would work. For example, "reflex_components_moment.moment". |
| `plugins: list[reflex_base.plugins.base.Plugin]` | List of plugins to use in the app. |
| `disable_plugins: list[type[reflex_base.plugins.base.Plugin]]` | List of plugin types to disable in the app. |
| `transport: typing.Literal['websocket', 'polling']` | The transport method for client-server communication. |

## Methods

| Signature | Description |
| --- | --- |
| `class_fields(cls) -> set[str]` | Get the fields of the config class. |
| `json(self) -> str` | Get the config as a JSON string. |
| `prepend_frontend_path(self, path: str) -> str` | Prepend the frontend path to a given path. |
| `prepend_backend_path(self, path: str) -> str` | Prepend the backend path to a given path. |
| `update_from_env(self) -> dict[str, typing.Any]` | Update the config values based on set environment variables. If there is a set env_file, it is loaded first. |
| `get_event_namespace(self) -> str` | Get the path that the backend Websocket server lists on. |
