Reflex requires Python 3.8+.
We highly recommend creating a virtual environment for your project.
venv is the standard option. conda and poetry are some alternatives.
We will go with venv here.
macOS (Apple Silicon) users should install Rosetta 2. Run this command:
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Replace my_app_name
with your project name. Switch to the new directory.
mkdir my_app_name cd my_app_name
python3 -m venv .venv source .venv/bin/activate
Reflex is available as a pip package.
pip install reflex
For Windows users, we recommend using Windows Subsystem for Linux (WSL) for optimal performance.
WSL users should refer to instructions for Linux above.
For the rest of this section we will work with native Windows (non-WSL).
We will go with venv here, for virtual environments.
mkdir my_app_name cd my_app_name
py -3 -m venv .venv .venv\\Scripts\\activate
pip install reflex
reflex init
The command will return four template options to choose from as shown below.
Initializing the web directory. Get started with a template: (0) blank (https://blank-template.reflex.run) - A minimal template (1) dashboard (https://dashboard.reflex.run) - A dashboard with tables and graphs (2) chat (https://chat.reflex.run) - A ChatGPT clone (3) sidebar (https://sidebar-template.reflex.run) - A template with a sidebar to navigate pages Which template would you like to use? (0):
From here select a template.
It is also possible to initialize your project based on a git repo. This is possible with any app in our gallery.
Run the command:
reflex init --template \{app_url}
Where a real example would look like this:
reflex init --template https://github.com/pynecone-io/pynecone-examples/tree/main/dalle
Run it in development mode:
reflex run
Your app runs at http://localhost:3000.
Reflex prints logs to the terminal. To increase log verbosity to help with debugging, use the --loglevel
flag:
reflex run --loglevel debug
Reflex will hot reload any code changes in real time when running in development mode. Your code edits will show up on http://localhost:3000 automatically.
The demo app showcases some of Reflex's features.
reflex demo