Config

reflex.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:

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 for complete details on all available options.

Fields

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

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 = 'sqlite:///reflex.db'

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.

enable_pyleak_monitoring: bool = False

PyLeak monitoring configuration for detecting event loop blocking and resource leaks.

pyleak_blocking_threshold: float = 0.1

Threshold in seconds for detecting event loop blocking operations.

pyleak_thread_grace_period: float = 0.2

Grace period in seconds for thread leak detection cleanup.

pyleak_action: LeakAction | None = None

Action to take when PyLeak detects issues

bun_path: Annotated = 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: Sequence = ('*',)

List of origins that are allowed to connect to the backend API.

react_strict_mode: bool = True

Whether to use React strict mode.

frontend_packages: 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 | None = None

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 from path_0.path_1... import path[-1], and calling it with no arguments would work. For example, "reflex.components.moment.moment".

plugins: list

List of plugins to use in the app.

disable_plugins: list

List of fully qualified import paths of plugins to disable in the app (e.g. reflex.plugins.sitemap.SitemapPlugin).

Methods

SignatureDescription
class_fields(cls) -> set[str]Get the fields of the config class.
json(self) -> strGet the config as a JSON string.
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) -> strGet the path that the backend Websocket server lists on.

Built with Reflex