Config
reflex_base.config.ConfigConfiguration 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:
Environment Variable Overrides
Any config value can be overridden by setting an environment variable with the REFLEX_
prefix and the parameter name in uppercase:
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,frontend_compression_formats - State Management:
state_manager_mode,state_auto_setters - Plugins:
plugins,disable_plugins
See the configuration docs for complete details on all available options.
Fields
| Prop | Description |
|---|---|
app_name: str | |
app_module_import: str | None = None | |
loglevel: LogLevel = <LogLevel.DEFAULT: 'default'> | |
frontend_port: int | None = None | |
frontend_path: str = '' | |
backend_port: int | None = None | |
backend_path: str = '' | |
api_url: str = 'http://localhost:8000' | |
deploy_url: str | None = 'http://localhost:3000' | |
backend_host: str = '0.0.0.0' | |
db_url: str | None = None | |
async_db_url: str | None = None | |
redis_url: str | None = None | |
telemetry_enabled: bool = True | |
bun_path: Path = PosixPath('/home/runner/.local/share/reflex/bun/bin/bun') | |
static_page_generation_timeout: int = 60 | |
cors_allowed_origins: collections.abc.Sequence[str] = ('*',) | |
vite_allowed_hosts: bool | list[str] = False | |
react_strict_mode: bool = True | |
frontend_compression_formats: list[str] = <function BaseConfig.<lambda> at 0x7f47ebbf49a0> | |
frontend_packages: list[str] = <class 'list'> | |
state_manager_mode: StateManagerMode = <StateManagerMode.DISK: 'disk'> | |
redis_lock_expiration: int = 10000 | |
redis_lock_warning_threshold: int = 1000 | |
redis_token_expiration: int = 3600 | |
env_file: str | None = None | |
state_auto_setters: bool = False | |
show_built_with_reflex: bool | None = None | |
is_reflex_cloud: bool = False | |
extra_overlay_function: str | None = None | |
plugins: list[reflex_base.plugins.base.Plugin] = <class 'list'> | |
disable_plugins: list[type[reflex_base.plugins.base.Plugin]] = <class 'list'> | |
transport: typing.Literal['websocket', 'polling'] = 'websocket' | |
app_name: str | The name of the app (should match the name of the app directory). |
app_module_import: str | None = None | The path to the app module. |
loglevel: LogLevel = <LogLevel.DEFAULT: 'default'> | The log level to use. |
frontend_port: int | None = 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 = 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 |
api_url: str = 'http://localhost:8000' | 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 = 'http://localhost:3000' | The url the frontend will be hosted on. |
backend_host: str = '0.0.0.0' | The url the backend will be hosted on. |
db_url: str | None = None | The database url used by rx.Model. |
async_db_url: str | None = None | The async database url used by rx.Model. |
redis_url: str | None = None | The redis url. |
telemetry_enabled: bool = True | Telemetry opt-in. |
bun_path: Path = PosixPath('/home/runner/.local/share/reflex/bun/bin/bun') | The bun path. |
static_page_generation_timeout: int = 60 | 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] = False | 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 = True | Whether to use React strict mode. |
frontend_compression_formats: list[str] = <function BaseConfig.<lambda> at 0x7f47ebbf49a0> | Pre-compressed frontend asset formats to generate for production builds. Supported values are "gzip", "brotli", and "zstd". Use an empty list to disable build-time pre-compression. |
frontend_packages: list[str] = <class 'list'> | Additional frontend packages to install. |
state_manager_mode: StateManagerMode = <StateManagerMode.DISK: 'disk'> | Indicate which type of state manager to use. |
redis_lock_expiration: int = 10000 | Maximum expiration lock time for redis state manager. |
redis_lock_warning_threshold: int = 1000 | Maximum lock time before warning for redis state manager. |
redis_token_expiration: int = 3600 | Token expiration time for redis state manager. |
env_file: str | None = None | Path to file containing key-values pairs to override in the environment; Dotenv format. |
state_auto_setters: bool = False | Whether to automatically create setters for state base vars. |
show_built_with_reflex: bool | None = None | Whether to display the sticky "Built with Reflex" badge on all pages. |
is_reflex_cloud: bool = False | Whether the app is running in the reflex cloud environment. |
extra_overlay_function: str | None = None | Extra overlay function to run after the app is built. Formatted such that |
plugins: list[reflex_base.plugins.base.Plugin] = <class 'list'> | List of plugins to use in the app. |
disable_plugins: list[type[reflex_base.plugins.base.Plugin]] = <class 'list'> | List of plugin types to disable in the app. |
transport: typing.Literal['websocket', 'polling'] = 'websocket' | 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. |