{"id":7664,"library":"reflex","title":"Reflex Web Framework","description":"Reflex is a full-stack web framework that allows developers to build web applications entirely in Python. It automatically generates a React-based frontend and manages backend logic, routing, and state. Currently at version 0.8.28.post1, Reflex maintains a rapid release cadence, frequently pushing new features and bug fixes.","status":"active","version":"0.8.28.post1","language":"en","source_language":"en","source_url":"https://github.com/reflex-dev/reflex","tags":["web-framework","full-stack","python","frontend","backend"],"install":[{"cmd":"pip install reflex","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.10 or higher, but less than Python 4.0","package":"python","optional":false}],"imports":[{"note":"The standard and recommended import alias for Reflex.","symbol":"reflex","correct":"import reflex as rx"},{"note":"While technically possible, directly importing 'State' is discouraged; it should be accessed as 'rx.State' after `import reflex as rx` for consistency and clarity within the framework's conventions.","wrong":"from reflex import State","symbol":"State","correct":"class State(rx.State):"}],"quickstart":{"code":"import reflex as rx\n\nclass State(rx.State):\n    count: int = 0\n\n    def increment(self):\n        self.count += 1\n\n    def decrement(self):\n        self.count -= 1\n\ndef index():\n    return rx.center(\n        rx.vstack(\n            rx.heading(State.count, size=\"9\"),\n            rx.hstack(\n                rx.button(\n                    \"Decrement\",\n                    color_scheme=\"red\",\n                    on_click=State.decrement,\n                ),\n                rx.button(\n                    \"Increment\",\n                    color_scheme=\"green\",\n                    on_click=State.increment,\n                ),\n            ),\n            spacing=\"5\",\n        ),\n        width=\"100vw\",\n        height=\"100vh\",\n    )\n\napp = rx.App(state=State)\napp.add_page(index, route=\"/\")","lang":"python","description":"This example creates a simple counter application. Save the code to a file (e.g., `your_app_name.py`). In your terminal, navigate to the directory containing the file. Run `reflex init` to initialize the project, then `reflex run` to start the development server. Access the app in your browser at `http://localhost:3000`."},"warnings":[{"fix":"Review the migration guide on the official Reflex documentation for detailed instructions. It's often easier to start a new Reflex project and port your Pynecone logic.","message":"Reflex was formerly known as Pynecone. Upgrading from Pynecone (versions < 0.5.0) to Reflex (0.5.0+) involves significant API changes and is not a direct in-place upgrade.","severity":"breaking","affected_versions":"<0.5.0 to >=0.5.0"},{"fix":"Pass the method/function name directly: `on_click=State.my_method` instead of `on_click=State.my_method()`.","message":"Event handlers in Reflex must be references to methods/functions, not function calls. Forgetting this will cause the handler to execute immediately instead of on the event.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Try clearing your browser cache or run `reflex run --clear-cache` to force a rebuild of the frontend assets.","message":"Sometimes, frontend changes might not reflect immediately due to browser or Reflex's build cache. This can lead to frustration during development.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Remove any calls to `app.compile()`. Define your app with `app = rx.App(state=State)` and use `app.add_page(page_component, route='/')` for each page. Deployment is handled by the `reflex deploy` CLI command.","message":"The `app.compile()` method for deploying apps is deprecated. Application deployment is now managed automatically when calling `reflex deploy`.","severity":"deprecated","affected_versions":">=0.6.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install reflex` in your active Python environment.","cause":"The Reflex library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'reflex'"},{"fix":"Ensure your virtual environment is activated before running `reflex` commands. If you're not using a virtual environment, verify `pip install reflex` completed successfully and your PATH is correctly configured for Python scripts.","cause":"The Reflex CLI executable is not in your system's PATH. This often happens if Reflex was installed in a virtual environment that is not activated, or if the installation was incomplete.","error":"reflex: command not found"},{"fix":"Try changing the backend port with `reflex run --backend-port <new_port>`. If the issue persists, ensure no other process is using port 8000. For project corruption, consider `reflex init --clear-cache` or regenerating the project.","cause":"This generic error can indicate several issues, such as the default port (8000) being in use, a corrupt `reflex` project setup, or conflicts with other applications.","error":"Error: The backend server failed to start."},{"fix":"First, ensure `reflex run` is still active and hasn't crashed. If it is, try hard refreshing your browser (Ctrl+Shift+R or Cmd+Shift+R). If the problem persists, stop the server and restart it with `reflex run --clear-cache`.","cause":"The Reflex development server might not be correctly detecting file changes, or the browser cache is serving an old version of the frontend.","error":"Changes in my Python code are not updating in the browser."}]}