{"id":7663,"library":"reflex-hosting-cli","title":"Reflex Hosting CLI","description":"The `reflex-hosting-cli` is a command-line interface tool designed to streamline the deployment of Reflex web applications to the Reflex hosting service. It provides commands for logging into the hosting platform and deploying projects with ease. Currently at version 0.1.62, it is under active development, often receiving updates in sync with the core Reflex framework.","status":"active","version":"0.1.62","language":"en","source_language":"en","source_url":"https://github.com/reflex-dev/reflex-hosting-cli","tags":["cli","hosting","deployment","reflex","frontend","web"],"install":[{"cmd":"pip install reflex-hosting-cli","lang":"bash","label":"Install `reflex-hosting-cli`"}],"dependencies":[{"reason":"Required as the core web framework whose applications are deployed by this CLI.","package":"reflex","optional":false},{"reason":"Command-line interface toolkit.","package":"click","optional":false},{"reason":"HTTP client for API interactions with the hosting service.","package":"requests","optional":false},{"reason":"Used for configuration file parsing.","package":"pyyaml","optional":false},{"reason":"Provides interactive command-line prompts.","package":"inquirer","optional":false},{"reason":"Used for building the command-line interface.","package":"typer","optional":false},{"reason":"For rich text and formatting in the terminal output.","package":"rich","optional":false}],"imports":[{"note":"The `reflex-hosting-cli` is primarily a command-line tool. Direct programmatic imports from its internal modules like `Config` are generally not part of typical usage and are not recommended for most users. Use `rx-host` via the terminal instead.","symbol":"Config","correct":"from reflex_hosting_cli.config import Config"}],"quickstart":{"code":"import subprocess\nimport os\nimport sys\n\n# This quickstart demonstrates the typical command-line flow for\n# deploying a Reflex application using reflex-hosting-cli.\n# It requires 'reflex' and 'reflex-hosting-cli' to be installed.\n\nproject_name = \"my_quickstart_app\"\n# Ensure we start clean for the quickstart\nif os.path.exists(project_name):\n    print(f\"Removing existing project '{project_name}' for a clean start...\")\n    subprocess.run([\"rm\", \"-rf\", project_name], check=True)\n\ntry:\n    print(f\"1. Initializing a new Reflex project: '{project_name}'...\")\n    # This command uses the 'reflex' CLI, a prerequisite.\n    subprocess.run([\"reflex\", \"init\", project_name], check=True, capture_output=True, text=True)\n    print(f\"   Project '{project_name}' initialized.\")\n    os.chdir(project_name)\n\n    print(\"\\n2. Logging into Reflex Hosting (requires manual interaction or pre-configured token)...\")\n    print(\"   Please run 'rx-host login' in your terminal and follow prompts.\")\n    print(\"   For this quickstart, we assume you are already logged in or will log in interactively.\")\n    # You would typically run: `subprocess.run([\"rx-host\", \"login\"], check=True)`\n    # This is commented out as it requires interactive input.\n\n    print(\"\\n3. Deploying the Reflex project...\")\n    print(\"   Note: This command requires active Reflex hosting credentials.\")\n    # Using --yes to skip interactive confirmation if possible.\n    # check=False because actual deployment success depends on external factors (account, network, etc.)\n    # and we want the quickstart script itself to complete without error due to failed deployment.\n    result = subprocess.run([\"rx-host\", \"deploy\", \"--yes\"], capture_output=True, text=True)\n    print(\"   Deployment command output:\")\n    print(result.stdout)\n    if result.stderr:\n        print(\"   Deployment command errors:\")\n        print(result.stderr)\n    print(\"\\n   Deployment command finished. Check the output above for status.\")\n\nexcept FileNotFoundError as e:\n    print(f\"\\nError: Command '{e.filename}' not found. Please ensure 'reflex' and 'reflex-hosting-cli' are installed and in your system's PATH.\", file=sys.stderr)\n    print(\"Install with: pip install reflex reflex-hosting-cli\", file=sys.stderr)\nexcept subprocess.CalledProcessError as e:\n    print(f\"\\nAn error occurred during command execution: {e}\", file=sys.stderr)\n    print(f\"STDOUT:\\n{e.stdout}\", file=sys.stderr)\n    print(f\"STDERR:\\n{e.stderr}\", file=sys.stderr)\nfinally:\n    # Always try to clean up\n    if os.path.basename(os.getcwd()) == project_name:\n        os.chdir(\"..\")\n    if os.path.exists(project_name):\n        print(f\"\\nCleaning up project directory '{project_name}'...\")\n        subprocess.run([\"rm\", \"-rf\", project_name], check=True)","lang":"python","description":"This quickstart demonstrates the typical workflow for deploying a Reflex application using the `reflex-hosting-cli`. It initializes a new Reflex project, then attempts to deploy it. Note that `rx-host login` needs to be run interactively to authenticate with the Reflex hosting service before deployment, or environment variables must be configured."},"warnings":[{"fix":"Always ensure both `reflex` and `reflex-hosting-cli` are updated to their latest compatible versions. Run `pip install --upgrade reflex reflex-hosting-cli`.","message":"The `reflex-hosting-cli` version must be compatible with your installed `reflex` framework version. Mismatched versions can lead to deployment failures or unexpected behavior.","severity":"breaking","affected_versions":"<0.1.62 may have issues with reflex >0.4.0"},{"fix":"Before your first deployment, run `rx-host login` in your terminal and follow the prompts to authenticate your account.","message":"Authentication is required before deploying. You must log in to the Reflex hosting service using `rx-host login`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the official Reflex documentation and the `rx-host --help` output for the most up-to-date command usage. Test deployments in a staging environment if possible.","message":"The CLI is under active development, and commands, options, or behavior might change between minor versions.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you have installed the package correctly with `pip install reflex-hosting-cli`. If installed, verify your PATH environment variable includes the directory where pip installs scripts (e.g., `~/.local/bin` on Linux/macOS, `Scripts` directory in Python installation on Windows).","cause":"The `reflex-hosting-cli` is not installed or its executable `rx-host` is not in your system's PATH.","error":"Command 'rx-host' not found"},{"fix":"Run `rx-host login` again in your terminal to re-authenticate and obtain a new token.","cause":"Your login session has expired, or the provided credentials for `rx-host login` were incorrect.","error":"Authentication Failed: Invalid credentials or token expired."},{"fix":"Navigate into the root directory of your Reflex project (the directory containing `rxconfig.py`) before running `rx-host deploy`.","cause":"The `rx-host deploy` command was executed from a directory that does not contain a valid Reflex project (i.e., it's missing the `rxconfig.py` file or other project structure).","error":"Error: No Reflex project found in the current directory."}]}