Skip to content

Commit 5f60036

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr6510-conflict-resolution
# Conflicts: # docs/app/reflex_docs/templates/docpage/docpage.py
2 parents 7ca8d91 + 05b66d3 commit 5f60036

92 files changed

Lines changed: 6058 additions & 1827 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
name: whitelist check
1+
name: docs whitelist check
22

33
on:
44
pull_request:
5+
paths:
6+
- 'docs/app/reflex_docs/whitelist.py'
7+
- '.github/workflows/docs_whitelist.yml'
58

69
permissions:
710
contents: read
811

912
jobs:
10-
reflex-web:
13+
check-whitelist:
1114
runs-on: ubuntu-latest
1215
steps:
1316
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1417
- name: Assert whitelist is empty
15-
run: echo -e "\nassert not WHITELISTED_PAGES, f'WHITELISTED_PAGES includes {WHITELISTED_PAGES}'" | cat "reflex_docs/whitelist.py" - | python3
18+
run: echo -e "\nassert not WHITELISTED_PAGES, f'WHITELISTED_PAGES includes {WHITELISTED_PAGES}'" | cat "docs/app/reflex_docs/whitelist.py" - | python3

README.md

Lines changed: 34 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
---
2222

2323
> [!NOTE]
24-
> 🚀 **Try [Reflex Build](https://build.reflex.dev/)** – our AI-powered app builder that generates full-stack Reflex applications in seconds.
24+
> Build faster with Reflex:
25+
>
26+
> - **[AI Builder](https://build.reflex.dev/)** - Generate full-stack Reflex apps in seconds.
27+
> - **[Agent Toolkit](https://reflex.dev/docs/ai/integrations/ai-onboarding/)** - Connect MCP and Skills to your coding assistant.
28+
> - **[App Management](https://reflex.dev/hosting)** - Deploy and manage your Reflex apps.
2529
2630
---
2731

@@ -33,7 +37,6 @@ Key features:
3337

3438
- **Pure Python** - Write your app's frontend and backend all in Python, no need to learn Javascript.
3539
- **Full Flexibility** - Reflex is easy to get started with, but can also scale to complex apps.
36-
- **Deploy Instantly** - After building, deploy your app with a [single command](https://reflex.dev/docs/hosting/deploy-quick-start/) or host it on your own server.
3740

3841
See our [architecture page](https://reflex.dev/blog/2024-03-21-reflex-architecture/#the-reflex-architecture) to learn how Reflex works under the hood.
3942

@@ -43,250 +46,77 @@ See our [architecture page](https://reflex.dev/blog/2024-03-21-reflex-architectu
4346

4447
## 🥳 Create your first app
4548

46-
### 1. Create the project directory
49+
Create a project, add Reflex, and start the development server with [uv](https://docs.astral.sh/uv/):
4750

48-
Replace `my_app_name` with your project name:
49-
50-
```bash
51+
```shell
5152
mkdir my_app_name
5253
cd my_app_name
53-
```
54-
55-
### 2. Install uv
56-
57-
Reflex recommends [uv](https://docs.astral.sh/uv/) for managing your project environment and dependencies.
58-
See the [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/) for your platform.
59-
60-
```bash
61-
# macOS/Linux
62-
curl -LsSf https://astral.sh/uv/install.sh | sh
63-
64-
# Windows (PowerShell)
65-
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
66-
```
67-
68-
### 3. Initialize the Python project
69-
70-
```bash
7154
uv init
72-
```
73-
74-
### 4. Add Reflex
7555

76-
Reflex requires Python 3.10+:
77-
78-
```bash
7956
uv add reflex
80-
```
81-
82-
### 5. Initialize the project
83-
84-
This command initializes a template app in your new directory:
85-
86-
```bash
8757
uv run reflex init
88-
```
89-
90-
### 6. Run the app
91-
92-
You can run this app in development mode:
93-
94-
```bash
9558
uv run reflex run
9659
```
9760

9861
You should see your app running at http://localhost:3000.
9962

10063
Now you can modify the source code in `my_app_name/my_app_name.py`. Reflex has fast refreshes so you can see your changes instantly when you save your code.
10164

102-
### Troubleshooting
103-
104-
If the `reflex` command is not on your PATH, run it through uv instead: `uv run reflex init` and `uv run reflex run`
105-
10665
## 🫧 Example App
10766

108-
Let's go over an example: creating an image generation UI around [DALL·E](https://platform.openai.com/docs/guides/images/image-generation?context=node). For simplicity, we just call the [OpenAI API](https://platform.openai.com/docs/api-reference/authentication), but you could replace this with an ML model run locally.
109-
110-
 
67+
Build an image generation app in Python with Reflex: define the UI, manage state in a class, and call an image model from an event handler.
11168

11269
<div align="center">
113-
<img src="https://raw.githubusercontent.com/reflex-dev/reflex/main/docs/images/dalle.gif" alt="A frontend wrapper for DALL·E, shown in the process of generating an image." width="550" />
70+
<video src="https://github.com/user-attachments/assets/aaff28ad-8b3c-43bf-967e-439ee34c8a87" width="900" controls muted poster="https://raw.githubusercontent.com/reflex-dev/reflex/main/docs/images/reflex-image-generation-app.png">
71+
<a href="https://github.com/user-attachments/assets/aaff28ad-8b3c-43bf-967e-439ee34c8a87">
72+
<img src="https://raw.githubusercontent.com/reflex-dev/reflex/main/docs/images/reflex-image-generation-app.png" alt="Preview of an image generation app built with Reflex" width="900">
73+
</a>
74+
</video>
11475
</div>
11576

116-
&nbsp;
117-
118-
Here is the complete code to create this. This is all done in one Python file!
119-
12077
```python
12178
import reflex as rx
12279
import openai
12380

124-
openai_client = openai.OpenAI()
81+
client = openai.AsyncOpenAI()
12582

12683

12784
class State(rx.State):
128-
"""The app state."""
129-
130-
prompt = ""
131-
image_url = ""
132-
processing = False
133-
complete = False
85+
prompt: str = ""
86+
image_url: str = ""
87+
processing: bool = False
13488

135-
def get_image(self):
136-
"""Get the image from the prompt."""
137-
if self.prompt == "":
138-
return rx.window_alert("Prompt Empty")
89+
@rx.event
90+
def set_prompt(self, value: str):
91+
self.prompt = value
13992

140-
self.processing, self.complete = True, False
93+
@rx.event
94+
async def generate(self):
95+
self.processing = True
14196
yield
142-
response = openai_client.images.generate(
143-
prompt=self.prompt, n=1, size="1024x1024"
97+
response = await client.images.generate(
98+
model="gpt-image-1.5",
99+
prompt=self.prompt,
144100
)
145-
self.image_url = response.data[0].url
146-
self.processing, self.complete = False, True
101+
self.image_url = f"data:image/png;base64,{response.data[0].b64_json}"
102+
self.processing = False
147103

148104

149105
def index():
150-
return rx.center(
151-
rx.vstack(
152-
rx.heading("DALL-E", font_size="1.5em"),
153-
rx.input(
154-
placeholder="Enter a prompt..",
155-
on_blur=State.set_prompt,
156-
width="25em",
157-
),
158-
rx.button(
159-
"Generate Image",
160-
on_click=State.get_image,
161-
width="25em",
162-
loading=State.processing,
163-
),
164-
rx.cond(
165-
State.complete,
166-
rx.image(src=State.image_url, width="20em"),
167-
),
168-
align="center",
169-
),
170-
width="100%",
171-
height="100vh",
106+
return rx.vstack(
107+
rx.heading("Image Generator"),
108+
rx.input(placeholder="Enter a prompt...", on_change=State.set_prompt),
109+
rx.button("Generate", on_click=State.generate, loading=State.processing),
110+
rx.image(src=State.image_url),
172111
)
173112

174113

175-
# Add state and page to the app.
176-
app = rx.App()
177-
app.add_page(index, title="Reflex:DALL-E")
178-
```
179-
180-
## Let's break this down.
181-
182-
<div align="center">
183-
<img src="https://raw.githubusercontent.com/reflex-dev/reflex/main/docs/images/dalle_colored_code_example.png" alt="Explaining the differences between backend and frontend parts of the DALL-E app." width="900" />
184-
</div>
185-
186-
### **Reflex UI**
187-
188-
Let's start with the UI.
189-
190-
```python
191-
def index():
192-
return rx.center(...)
193-
```
194-
195-
This `index` function defines the frontend of the app.
196-
197-
We use different components such as `center`, `vstack`, `input`, and `button` to build the frontend. Components can be nested within each other
198-
to create complex layouts. And you can use keyword args to style them with the full power of CSS.
199-
200-
Reflex comes with [60+ built-in components](https://reflex.dev/docs/library) to help you get started. We are actively adding more components, and it's easy to [create your own components](https://reflex.dev/docs/wrapping-react/overview/).
201-
202-
### **State**
203-
204-
Reflex represents your UI as a function of your state.
205-
206-
```python
207-
class State(rx.State):
208-
"""The app state."""
209-
210-
prompt = ""
211-
image_url = ""
212-
processing = False
213-
complete = False
214-
```
215-
216-
The state defines all the variables (called vars) in an app that can change and the functions that change them.
217-
218-
Here the state is comprised of a `prompt` and `image_url`. There are also the booleans `processing` and `complete` to indicate when to disable the button (during image generation) and when to show the resulting image.
219-
220-
### **Event Handlers**
221-
222-
```python
223-
def get_image(self):
224-
"""Get the image from the prompt."""
225-
if self.prompt == "":
226-
return rx.window_alert("Prompt Empty")
227-
228-
self.processing, self.complete = True, False
229-
yield
230-
response = openai_client.images.generate(prompt=self.prompt, n=1, size="1024x1024")
231-
self.image_url = response.data[0].url
232-
self.processing, self.complete = False, True
233-
```
234-
235-
Within the state, we define functions called event handlers that change the state vars. Event handlers are the way that we can modify the state in Reflex. They can be called in response to user actions, such as clicking a button or typing in a text box. These actions are called events.
236-
237-
Our DALL·E app has an event handler, `get_image` which gets this image from the OpenAI API. Using `yield` in the middle of an event handler will cause the UI to update. Otherwise the UI will update at the end of the event handler.
238-
239-
### **Routing**
240-
241-
Finally, we define our app.
242-
243-
```python
244114
app = rx.App()
115+
app.add_page(index, title="Reflex:Image Generation")
245116
```
246117

247-
We add a page from the root of the app to the index component. We also add a title that will show up in the page preview/browser tab.
248-
249-
```python
250-
app.add_page(index, title="DALL-E")
251-
```
252-
253-
You can create a multi-page app by adding more pages.
254-
255-
## 📑 Resources
256-
257-
<div align="center">
258-
259-
📑 [Docs](https://reflex.dev/docs/getting-started/introduction) &nbsp; | &nbsp; 🗞️ [Blog](https://reflex.dev/blog) &nbsp; | &nbsp; 📱 [Component Library](https://reflex.dev/docs/library) &nbsp; | &nbsp; 🖼️ [Templates](https://reflex.dev/templates/) &nbsp; | &nbsp; 🛸 [Deployment](https://reflex.dev/docs/hosting/deploy-quick-start) &nbsp;
260-
261-
</div>
262-
263-
## ✅ Status
264-
265-
Reflex launched in December 2022 with the name Pynecone.
266-
267-
🚀 Introducing [Reflex Build](https://build.reflex.dev/) — Our AI-Powered Builder
268-
Reflex Build uses AI to generate complete full-stack Python applications. It helps you quickly create, customize, and refine your Reflex apps — from frontend components to backend logic — so you can focus on your ideas instead of boilerplate code. Whether you’re prototyping or scaling, Reflex Build accelerates development by intelligently scaffolding and optimizing your app’s entire stack.
269-
270-
Alongside this, [Reflex Cloud](https://cloud.reflex.dev) launched in 2025 to offer the best hosting experience for your Reflex apps. We’re continuously improving the platform with new features and capabilities.
271-
272-
Reflex has new releases and features coming every week! Make sure to :star: star and :eyes: watch this repository to stay up to date.
273-
274-
## Contributing
275-
276-
We welcome contributions of any size! Below are some good ways to get started in the Reflex community.
277-
278-
- **Join Our Discord**: Our [Discord](https://discord.gg/T5WSbC2YtQ) is the best place to get help on your Reflex project and to discuss how you can contribute.
279-
- **GitHub Discussions**: A great way to talk about features you want added or things that are confusing/need clarification.
280-
- **GitHub Issues**: [Issues](https://github.com/reflex-dev/reflex/issues) are an excellent way to report bugs. Additionally, you can try and solve an existing issue and submit a PR.
281-
282-
We are actively looking for contributors, no matter your skill level or experience. To contribute check out [CONTRIBUTING.md](https://github.com/reflex-dev/reflex/blob/main/CONTRIBUTING.md)
283-
284118
## All Thanks To Our Contributors:
285119

286120
<a href="https://github.com/reflex-dev/reflex/graphs/contributors">
287121
<img src="https://contrib.rocks/image?repo=reflex-dev/reflex" />
288122
</a>
289-
290-
## License
291-
292-
Reflex is open-source and licensed under the [Apache License 2.0](https://raw.githubusercontent.com/reflex-dev/reflex/main/LICENSE).

docs/advanced_onboarding/code_structure.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ import reflex as rx
228228
class State(rx.State):
229229
v: str = "foo"
230230

231+
@rx.event
232+
def set_v(self, value: str):
233+
self.v = value
234+
231235

232236
@lru_cache
233237
def foo():

docs/app/agent_files/_plugin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,10 @@ class AgentFilesPlugin(Plugin):
892892
def get_static_assets(
893893
self, **context: Unpack[CommonContext]
894894
) -> Sequence[tuple[Path, str | bytes]]:
895-
return [
896-
(Dirs.PUBLIC / path, content) for path, content in generate_agent_files()
897-
]
895+
from reflex_base.config import get_config
896+
897+
root = Path(Dirs.PUBLIC)
898+
if frontend_path := get_config().frontend_path:
899+
# Make sure the pre-rendered HTML does not get overwritten by md files.
900+
root = root / frontend_path.lstrip("/")
901+
return [(root / path, content) for path, content in generate_agent_files()]

docs/app/assets/tailwind-theme.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import 'tailwindcss-scroll-mask';
12
@import "tailwindcss-animated";
23

34
@custom-variant dark (&:where(.dark, .dark *));

0 commit comments

Comments
 (0)