R

ReflexKR

Reflex Docs

Full-Stack Python Web Development with Reflex

·

Course overview

1

Meet Reflex and set up your environment

2

Drawing the screen with components

3

State and Vars: let data draw the screen

4

Events and forms: adding customers

5

Shaping data and charts

6

Wrap-up, debugging and next steps

·

Appendix

Full-Stack Python Web Development with Reflex
Lesson 1

Time 0:00–0:35

Meet Reflex and set up your environment

By the end of this lesson, the default Reflex app will be running in your browser, and you'll be able to explain in one sentence how Reflex turns Python code into a web app.

1-1. What is Reflex? (10 min)

A web app usually has two parts:

  • Frontend: the UI that runs in the browser, usually built with HTML, CSS and JavaScript (React and friends).
  • Backend: the logic and data that run on the server, built with Python (Django, FastAPI) or similar.

Normally you have to learn both languages and design an API between them. Reflex is a full-stack framework that lets you write both the frontend and the backend in Python.

It works in three steps:

  1. Compile: the Python functions that build your UI (components) run once when the app starts and are turned into React code. The output goes into the .web/ folder.
  2. State lives on the server: your data (State) and event handlers run as Python on the server.
  3. Sync over WebSocket: when you click a button, the browser sends an event to the server, the server sends back only the state that changed, and the page re-renders automatically.
How Reflex works · compiled once, events round-trip over WebSocket

The single Python file on the left splits two ways. The UI functions are compiled to React and shipped to the browser, while State stays on the server and syncs with the page through the ② → ③ round trip.

Instructor note — These three steps come up again and again throughout the course. Sum them up in one line, "UI functions run once, event handlers run every time," and bring it back in Lesson 3 when you explain why you can't use if.

1-2. Set up your environment (10 min)

Install uv: uv is a tool that manages Python versions, virtual environments and packages in one place.

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

Check Node.js: Reflex uses Node.js or Bun to install and run the frontend (React) packages. Reflex 0.10 requires Node 22.22.0 or later.

node -v   # should be v22.22.0 or later

1-3. Create and run a project (10 min)

uv init tutorial_261019        # create a Python project
cd tutorial_261019
uv add reflex                  # install reflex (recorded in pyproject.toml)
uv run reflex init             # scaffold a Reflex app (pick a template)
uv run reflex run              # start the dev server
  • uv run runs a command inside the project's virtual environment (.venv). You don't need to activate the environment yourself.
  • reflex init asks you to pick a template. To start from an empty app, you can pass it directly: uv run reflex init --template blank.
  • Once reflex run is up, open the App running at: http://localhost:3000 address from the log in your browser. If port 3000 is taken, it moves to 3001 or another port.
  • By default, the frontend runs on port 3000 and the backend on port 8000.
  • The first run can take 1–3 minutes while it downloads the frontend packages. You need an internet connection.
  • To stop the server, press Ctrl + C in the terminal.

Check your browser — Right after creating the app with --template blank, opening http://localhost:3000 should show this screen. The sun icon in the top-right corner toggles dark mode.

localhost:3000

Live preview

Welcome to Reflex!

Get started by editing tutorial_261019/tutorial_261019.py

Default screen of the reflex init blank template

1-4. Two common errors on Windows (5 min)

We actually ran into these while preparing the course. Your students are likely to hit them too, so warn them up front.

SymptomCauseFix
UnicodeEncodeError: 'cp949' codec can't encode character '—' during reflex initWindows uses a non-UTF-8 system code page (e.g. cp949 on Korean Windows, cp932 on Japanese, cp936/GBK on Chinese), so writing AGENTS.md fails on a special characterRun setx PYTHONUTF8 1, restart the terminal, then run reflex init again
restartWithMergedOptions() was called, but the process has already been restarted during reflex runNode is older than the required version, so Reflex forces the Bun runtime, and the React Router restart fails on that pathUpgrade Node to 22.22.0 or later (e.g. winget upgrade --id OpenJS.NodeJS.22)
  • Environment variables set with setx only apply to terminals you open afterwards. If you use the VS Code terminal, restart VS Code too.
  • If winget says it can't find an installed package, run winget list --name Node to check the actual package ID.

Checkpoint

  • node -v shows 22.22.0 or later.
  • After uv run reflex run, you can see the default page in your browser.
  • You can explain in your own words: "UI functions are compiled once; event handlers run on the server every time."

← Previous

Course overview

Next →

Lesson 2 · Drawing the screen with components

Get news about new lessons

We'll email you when this course gets new lessons or a follow-up course opens.

We collect: your email address · Purpose: news about new lessons or the launch of this course · Kept until: you ask us to remove it. We never use it for anything else or share it. Reply to any notice email and we'll delete it right away.

Questions & answers

Ask anything about this lesson. Questions from every language version of this page appear together.

Shown as plain text, without links or formatting.

R

ReflexKR

Learn Python and Reflex by doing. Every example was run and verified on Reflex 0.10.0.

ReflexKR is free, with no banner ads. If it helped you, you can support it with a coffee. ☕ Buy us a coffee

Affiliate disclosure
한국어English日本語简体中文EspañolDeutsch

© 2026 ReflexKR · Since 2026 · CC BY-NC 4.0

Built with Reflex