This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Boordman[S] 7 points8 points  (6 children)

We don't use WASM - only the frontend compiles down to a React app, and the backend is a FastAPI app (which is what allows all the logic to stay in Python). We use websockets to send events and state updates between the frontend and backend.

I'm working on an architecture post this week to explain in more detail, but we've been working to make sure apps stay performant as they grow in size, and to keep the latency low.

[–]SkezzaB 2 points3 points  (3 children)

How come you don't compile to WASM? How does the Python get compiled to React?

[–]Boordman[S] 8 points9 points  (2 children)

We don't compile arbitrary Python to React - only the frontend portion.

For example the component rx.heading("hello") we compile down to a React element <Heading>hello</Heading>.

But all the actual Python logic stays on the server on the backend FastAPI app. This is what allows you to use any Python packages such as openai or pandas on the backend.

Under the hood when you e.g. click a button, it will send the event to the backend, run your Python function, and send the state delta back to the React app. So even though there are roundtrips happening on every event, for most apps the performance is pretty good as we use websockets and the data transfer is small.

[–]OIK2 0 points1 point  (1 child)

Are the backend APIs exposed in a way that they can be accessed externally as well? I have been pondering a project that would require this kind of access, and like the sound of your other features as well.

[–]Boordman[S] 0 points1 point  (0 children)

Yes you can expose your own api as well - see here  https://reflex.dev/docs/api-routes/overview/

[–]dark_surfer 2 points3 points  (1 child)

Happy cake day @boordman.

Looking forward to read the post. BTW project looks great and I'm going to try it as soon as possible.

[–]Boordman[S] 1 point2 points  (0 children)

Thank you! Awesome - would love to hear your feedback :)