For AI agents: the complete documentation index is at llms.txt. Markdown versions are available by appending .md or sending Accept: text/markdown.
Reflex Logo
Docs Logo
Api Reference

/

Config

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:

Environment Variable Overrides

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

See the configuration docs for a guided overview of the most commonly tweaked settings.

Fields

PropEnvironment Variable
app_name: strREFLEX_APP_NAME

The name of the app (should match the name of the app directory).

app_module_import: Optional[str] = NoneREFLEX_APP_MODULE_IMPORT

The path to the app module.

loglevel: LogLevel = <LogLevel.DEFAULT: 'default'>REFLEX_LOGLEVEL

The log level to use.

frontend_port: Optional[int] = NoneREFLEX_FRONTEND_PORT

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 = ''REFLEX_FRONTEND_PATH

The path to run the frontend on. For example, "/app" will run the frontend on http://localhost:3000/app

backend_port: Optional[int] = NoneREFLEX_BACKEND_PORT

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 = ''REFLEX_BACKEND_PATH

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 = 'http://localhost:8000'REFLEX_API_URL

The backend url the frontend will connect to. Only needs to be set when the backend is listening on a different address than the frontend.

deploy_url: Optional[str] = 'http://localhost:3000'REFLEX_DEPLOY_URL

The url the frontend will be hosted on. Used to build absolute frontend URLs, e.g. links in the generated sitemap.xml.

backend_host: str = '0.0.0.0'REFLEX_BACKEND_HOST

The url the backend will be hosted on.

db_url: Optional[str] = NoneREFLEX_DB_URL

The database url used by rx.Model.

async_db_url: Optional[str] = NoneREFLEX_ASYNC_DB_URL

The async database url used by rx.Model.

redis_url: Optional[str] = NoneREFLEX_REDIS_URL

The redis url.

telemetry_enabled: bool = TrueREFLEX_TELEMETRY_ENABLED

Telemetry opt-in.

bun_path: Path = PosixPath('/home/runner/.local/share/reflex/bun/bin/bun')REFLEX_BUN_PATH

The bun path.

frozen_lockfile: bool = TrueREFLEX_FROZEN_LOCKFILE

Run frontend package manager in lockfile-enforcing mode (only honored by bun).

static_page_generation_timeout: int = 60REFLEX_STATIC_PAGE_GENERATION_TIMEOUT

Timeout to do a production build of a frontend page.

cors_allowed_origins: Sequence[str] = ('*',)REFLEX_CORS_ALLOWED_ORIGINS

Comma separated list of origins that are allowed to connect to the backend API.

vite_allowed_hosts: bool | list[str] = FalseREFLEX_VITE_ALLOWED_HOSTS

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 = TrueREFLEX_REACT_STRICT_MODE

Whether to use React strict mode.

frontend_compression_formats: list[str]REFLEX_FRONTEND_COMPRESSION_FORMATS

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] = []REFLEX_FRONTEND_PACKAGES

Additional frontend packages to install.

state_manager_mode: StateManagerMode = <StateManagerMode.DISK: 'disk'>REFLEX_STATE_MANAGER_MODE

Indicate which type of state manager to use.

redis_lock_expiration: int = 10000REFLEX_REDIS_LOCK_EXPIRATION

Maximum expiration lock time for redis state manager.

redis_lock_warning_threshold: int = 1000REFLEX_REDIS_LOCK_WARNING_THRESHOLD

Maximum lock time before warning for redis state manager.

redis_token_expiration: int = 3600REFLEX_REDIS_TOKEN_EXPIRATION

Token expiration time for redis state manager.

env_file: Optional[str] = NoneREFLEX_ENV_FILE

Path to file containing key-values pairs to load into the environment; Dotenv format. Multiple files may be separated by os.pathsep. Requires the python-dotenv package.

state_auto_setters: bool = FalseREFLEX_STATE_AUTO_SETTERS

Whether to automatically create setters for state base vars.

default_color_mode: Literal["system", "light", "dark"] = 'system'REFLEX_DEFAULT_COLOR_MODE

The default color mode for the app: "system" (follow the OS preference), "light", or "dark". Applies to the built-in color mode switcher and color_mode_cond without requiring a radix theme.

show_built_with_reflex: Optional[bool] = NoneREFLEX_SHOW_BUILT_WITH_REFLEX

Whether to display the sticky "Built with Reflex" badge on all pages.

is_reflex_cloud: bool = FalseREFLEX_IS_REFLEX_CLOUD

Whether the app is running in the reflex cloud environment.

extra_overlay_function: Optional[str] = NoneREFLEX_EXTRA_OVERLAY_FUNCTION

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".

hydrate_fallback: Optional[str] = NoneREFLEX_HYDRATE_FALLBACK

Function returning the component shown while the page is hydrating (React Router's HydrateFallback), used when App.hydrate_fallback is not set. Formatted such that from path_0.path_1... import path[-1], and calling it with no arguments would work. For example, "my_app.components.loading".

plugins: list[Plugin] = []REFLEX_PLUGINS

List of plugins to use in the app.

disable_plugins: list[type[Plugin]] = []REFLEX_DISABLE_PLUGINS

List of plugin types to disable in the app.

transport: Literal["websocket", "polling"] = 'websocket'REFLEX_TRANSPORT

The transport method for client-server communication.

Methods

SignatureDescription
class_fields() -> set[str]Get the fields of the config class.
json() -> strGet the config as a JSON string.
prepend_frontend_path(path: str) -> strPrepend the frontend path to a given path.
prepend_backend_path(path: str) -> strPrepend the backend path to a given path.
update_from_env() -> dict[str, Any]Update the config values based on set environment variables. If there is a set env_file, it is loaded first.
get_event_namespace() -> strGet the path that the backend Websocket server lists on.
Built with Reflex