github reflex-dev/reflex v0.12.0a1

pre-releaseone hour ago

Breaking Changes

  • Background tasks now receive the state itself instead of a StateProxy. A state is writable while the running event holds its lock; outside of that, like in a background task, writes raise ImmutableStateError until the state is entered with async with self. StateProxy, ReadOnlyStateProxy and ImmutableMutableProxy are removed from reflex.istate.proxy, and rx.get_state returns the state, writable inside async with it. (#7313)
  • Two state mixins that do not inherit from one another can no longer both declare a var of the same name: creating the state that combines them raises MixinVarNameConflictError instead of silently giving the two mixins one var. Declare the var on the state that combines them, which both mixins then use, rename it in one of the mixins, or declare it in a mixin both inherit from. A mixin may still declare without a default (count: int) a var that the parent state or another mixin declares, to type it for its own code. (#7381)
  • Form on_submit now builds form_data only from each control's name, as deprecated in 0.10.1: a control's id no longer adds a field. Give every submitted control a name, e.g. rx.input(id="email", name="email"). reflex now requires reflex-components-core 0.12.0 or newer, which builds form data this way. (#7540)
  • An event trigger made of one event handler now returns a result stream that settles when the handler finishes, instead of a promise that resolved once the event was sent. A component that awaits the value its callback returns now waits for the handler, and sees a rejection if the handler raises. Calls that .throttle(), .debounce() or .temporal drop or delay now return a stream too, where they returned undefined: a debounced call gets the stream of the dispatch its window ends with, a throttled-out call the stream of the last dispatch while it is open, and any other skipped call a stream that is already complete. (#7761)
  • The compiled value of a computed var that reads another computed var declared with initial_value, shown until the page connects, is now derived from that initial value, so the reading getter must accept it. A getter that calls self.name.upper() on @rx.var(initial_value=None) def name(self) -> str now fails to compile: give the initial value the getter's type, such as initial_value="", or handle None in the reading getter. See Initial Values. (#7905)
  • Reflex now uses httpx2 for HTTP requests and verifies HTTPS certificates against the operating system's certificate store. Applications that import httpx must declare it as their own dependency or migrate to httpx2; see HTTP clients and certificates. (#7970)
  • The backend reads the client token only from the Socket.IO CONNECT auth payload, so it no longer appears in the socket URL, where proxies, access logs and security scanners picked it up. A custom Socket.IO client sends it as auth={"token": client_token}, together with its session cookie: one that sends the token only as ?token= in the URL gets a new token and fresh state on every connect. See the browser sessions guide. (#8089)

Deprecations

  • @rx.dynamic is deprecated and will be removed in 1.0. (#8079)

Features

  • Add the state_explicit_event_handlers config option. When enabled, only methods decorated with @rx.event become event handlers; other public state methods stay plain Python methods. (#7033)

  • reflex run reads the session signing keys from REFLEX_SECRET_KEY. Without it, reflex run generates a temporary key for that run. A configured key shorter than 32 bytes stops the run at startup. (#7361)

  • Add browser sessions using HttpOnly cookies and a POST /_reflex/session endpoint that issues a client token bound to the requesting session. Sessions scope HTTP and custom WebSocket state access; authenticated sockets can renew their cookie credentials without losing client state. See the browser sessions guide for configuration and migration. (#7362)

  • An event handler's non-event yield and return values now reach the frontend code that dispatched the event: addEvents(...) returns a result stream to iterate with for await or await for the last value, and it rejects when the handler raises. A trigger made of one event handler returns the stream too, so it can be passed to a React prop expecting an async callback (like loadOptions). Yielding a non-event value no longer raises TypeError; events are still chained rather than sent, and events mixed with other values or an unawaited coroutine still raise it. See Yielding Values to the Frontend.

    @rx.event
    def load_rows(self, page: int) -> list[dict]:
        return db.rows(page)
    const rows = await addEvents([ReflexEvent("state.load_rows", { page })]);

    (#7761)

  • A background event handler can now await rx.call_script, rx.call_function and rx.run_script outside async with self to get the script's result directly, instead of passing a callback:

    @rx.event(background=True)
    async def measure(self):
        size = await rx.call_script("({w: window.innerWidth, h: window.innerHeight})")
        async with self:
            self.width = size["w"]

    A script error raises BrowserScriptError, a missing result TimeoutError (browser_call_timeout in rxconfig.py, or timeout= per call), and a tab that is closed, reloaded or away longer than browser_call_grace_period raises BrowserDisconnectedError. Awaiting inside async with self raises EventHandlerTypeError. See Awaiting Results. (#7955)

  • Add rx.plugins.UploadPlugin, which serves the upload endpoint, /_upload. Apps that configure neither plugins nor disable_plugins for it serve the endpoint when they use uploads, as before. An app that only sends rx.upload_files from a component of its own adds it to plugins to have the endpoint served. Add it to disable_plugins to never serve the endpoint, in which case rx.upload and rx.get_upload_url raise a ConfigError. See UploadPlugin. (#8090)

Bug Fixes

  • Events from a client linked to an rx.SharedState no longer re-send the unchanged router data with every state update. (#6841)
  • Creating an rx.App no longer re-executes rxconfig.py, so classes defined there keep their State registration and Python class identity. It also no longer re-reads the environment, so a REFLEX_* variable that the app module sets (for example with load_dotenv()) no longer reaches the config under reflex run; load such files with env_file in rxconfig.py instead. (#7144)
  • Remove deleted app assets from subsequent frontend builds and exports while preserving plugin-generated public files. (#7233)
  • A state var declared with dataclasses.field(...) now raises a StateValueError when the class is defined, naming the var and pointing to rx.field(...), instead of the app failing to compile with TypeError: cannot pickle 'mappingproxy' object. (#7308)
  • AppHarness now points the development frontend at localhost for the backend API, so browser cookies remain same-site during tests. (#7364)
  • A var that a state mixin declares without a default, like count: int, no longer replaces the var of that name declared by a parent state of the class the mixin is combined into. The mixin uses the parent's var, as re-annotating it on the substate does. Re-annotating such a var with another type, like count: str, now gives it that type's default instead of the original type's. (#7381)
  • State vars changed with an in-place operator (+=, *=, |=, &=, -=, ^=) now mark the field dirty, so the update reaches the frontend. This covers mutating a local alias of a state var, like items = self.items; items += ["b"], which previously changed the backend value without sending it. The same operators on a state proxy outside a mutable async context now raise ImmutableStateError instead of silently mutating the state. (#7713)
  • Custom frontend and backend exception handlers now resolve their annotations in the handler's own module, so annotating exception with an application-defined exception class no longer crashes app startup with NameError. Handlers wrapped with a functools.wraps decorator are now accepted too. (#7714)
  • reflex run no longer fails to start when REFLEX_HOT_RELOAD_EXCLUDE_PATHS lists a path that does not exist. (#7743)
  • Preserve state changes made by event handlers that raise or are cancelled when using the disk state manager (the default), matching the in-memory and Redis managers. (#7769)
  • Fixed a hang with rx.SharedState: an event cancelled or failing while taking the locks of its linked states no longer leaves the locks it already took held. With the in-memory state manager this blocked every client linked to that token until restart; the disk and Redis managers freed the lock only later, through garbage collection or lock expiry. (#7776)
  • reflex run, reflex export and reflex compile no longer skip the frontend compile, and serve or export the previous pages, after a dev run that was stopped before its backend worker loaded the app. (#7829)
  • Backend-only starts without a frontend build now register the same bundled libraries a frontend compile would, including implicitly enabled Radix Themes, so reflex-enterprise apps no longer fail with Library @radix-ui/themes is not bundled. The derived libraries are saved to .web/backend/bundled_libraries.json, so later starts skip that work. (#7849)
  • The deprecation warning for decorators placed above @rx.event now names every affected method of a state, instead of only the first one in each class. (#7867)
  • router.session.client_ip now normalizes the X-Forwarded-For entry selected by trusted_proxy_hops to an IP address, dropping any port and IPv6 brackets and unmapping IPv4-mapped IPv6 addresses, and falls back to the connection's peer address when the entry is not a valid address. (#7880)
  • The rejected event websocket origin warning now names the trusted X-Forwarded-Proto and, when only the scheme differs, says the page was loaded over http while the trusted proxy reports https instead of blaming Host forwarding. (#7892)
  • Fix reflex run failing to start the frontend on Windows installs that have bun but no Node.js (restartWithMergedOptions() was called, but the process has already been restarted). (#7895)
  • Lifecycle events and add_hooks of a component under rx.cond, rx.match or rx.foreach in an @rx.memo function now run with their branch and once per loop item, as on a page, instead of when the memo mounts. A component that spreads the memo's rx.RestProp or wraps its children keeps the old behavior. (#7903)
  • A computed var, sync or async, that reads another computed var declared with initial_value now sees that initial value while the initial state is compiled, instead of running the other var's getter, so reflex export and reflex run no longer fail when that getter needs a database or a request. (#7905)
  • app.add_page(...) now raises BackendVarFormatError when on_load is a backend var such as State._handler, instead of accepting it. (#7908)
  • The compile progress bar no longer ends one step past its total, as in 16/15. (#7912)
  • Modifying a state with app.modify_state no longer logs an "Attempting to send delta to disconnected client" warning when no client is connected with the token, such as the shared token of a shared state. The clients linked to a shared state still get the update. (#7921)
  • With redis, a state update sent from another app instance right after a client's first connection to an instance is no longer lost. (#7938)
  • reflex deploy now shows its progress and success messages after the export step, not only warnings and errors. (#7947)
  • reflex db makemigrations no longer crashes with a CompileError when an added column defaults to an Enum member or a JSON list or dict. An Enum default becomes the server default; existing rows get NULL in a nullable JSON column, with a warning, and a NOT NULL one is refused until it has a server_default. (#7958)
  • An explicit --loglevel info is no longer ignored when INFO is already the current level. Like any other --loglevel value, it now reaches REFLEX_LOGLEVEL and overrides a loglevel set in rxconfig.py. (#7960)
  • Shared assets (rx.asset(..., shared=True)) are now copied straight into the app's build when a symlink cannot be created, such as on Windows without Developer Mode, instead of stopping the app from starting. (#7962)
  • A background event handler that overrides one from a mixin or a parent state can call it with await super().handler() again, instead of raising ImmutableStateError. (#7964)
  • reflex rename now updates imports of the app module, such as from myapp.myapp import app and from .myapp import State, and a custom app_module_import in rxconfig.py. Before, the renamed app failed with ModuleNotFoundError. (#7969)
  • A page added without image= no longer gets an og:image meta tag pointing at the relative favicon.ico, which link previews could not resolve. Pass an absolute URL as image= to set a page's preview image. (#8006)
  • reflex init no longer deletes or replaces files already in the directory. A template's files are added only where nothing has their name, and init warns about each file it kept, such as a pyproject.toml or README.md from a remote template. When a file or folder named after the app already exists, init stops with an error before it writes anything. (#8025)
  • reflex run, export and compile reinitialize an existing .web directory when the frontend template changed without a version bump, e.g. in an editable install, instead of building with stale or missing template files. (#8028)
  • Raise the minimum python-engineio to 4.13.2 (CVE-2026-48802, CVE-2026-48809: denial of service) and python-socketio to 5.16.2 (CVE-2025-61765: pickle deserialization in some multi-server deployments; CVE-2026-48804: denial of service), so an install that resolves the lowest allowed versions no longer picks up a vulnerable release. (#8038)
  • reflex export --zip-dest-dir no longer packs the zips it writes into backend.zip when the directory is inside the app. Exporting there a second time made backend.zip archive itself and grow until the disk was full. A destination directory that does not exist yet is now created instead of crashing the export, and --exclude-from-backend now also applies to files under .web/backend. (#8042)
  • A stylesheet given to rx.App(stylesheets=...) as an rx.asset url is found again: the ?v= version query rx.asset appends and a configured frontend_path prefix are not part of the file's path, and a shared asset that could not be symlinked is read from its source. (#8048)
  • rx.asset(shared=True) now links an asset whose path has directories, such as rx.asset("icons/logo.svg", shared=True), instead of failing because the directory below the external assets folder did not exist. (#8048)
  • With REFLEX_OPLOCK_ENABLED, Redis state managers no longer keep a lock in memory for every token after its local state lease ends. (#8054)
  • Reflex applies its own CORS middleware once per request, so a backend response no longer repeats Origin in Vary for each Reflex CORS layer. Reflex no longer adds CORS middleware to the Starlette or FastAPI app passed as api_transformer. CORS middleware that your own transformer adds still runs in addition to the Reflex layer. (#8060)
  • An app that stops using uploads now stops serving /_upload after its next compile. If your app sends rx.upload_files from a component of its own, without rx.upload, add rx.plugins.UploadPlugin() to plugins to keep the endpoint. See UploadPlugin. (#8090)

Performance

  • Reduce the per-var overhead of building the state updates sent to the client after each event. (#6162)
  • Avoid rescanning unexpired disk state files on every idle write-queue tick. (#7060)
  • Production backend workers now freeze the Python heap once the app is built, so full garbage collections skip the app's long-lived objects. This covers workers that build the app themselves (spawned granian workers, uvicorn and gunicorn), which previously walked the whole app on every full collection. (#7945)
  • rx.asset(shared=True) finds its calling module without inspect.stack(), which read the source of every frame on the stack on each call. (#8048)

Documentation

Miscellaneous

  • reflex.istate.proxy, reflex.istate.delta and reflex.istate.manager.token now re-export their modules from reflex_base.state, where the core of rx.State lives. (#7314)
  • Reflex applies its own npm overrides only when overrides in package.json is a JSON object; any other value is left in place with a warning for you to fix. (#8086)

Don't miss a new reflex release

NewReleases is sending notifications on new releases.