Getting Started#

What You’ll Learn
Installing ReactPy

Learn how ReactPy can be installed in a variety of different ways - with different web servers and even in different frameworks.

Running ReactPy

See how ReactPy can be run with a variety of different production servers or be added to existing applications.

The fastest way to get started with ReactPy is to try it out in a Juptyer Notebook. If you want to use a Notebook to work through the examples shown in this documentation, you’ll need to replace calls to reactpy.run(App) with a line at the end of each cell that constructs the App() in question. If that doesn’t make sense, the introductory notebook linked below will demonstrate how to do this:

../../_images/reactpy-in-jupyterlab.gif

Section 1: Installing ReactPy#

The next fastest option is to install ReactPy along with a supported server (like starlette) with pip:

pip install "reactpy[starlette]"

To check that everything is working you can run the sample application:

python -c "import reactpy; reactpy.run(reactpy.sample.SampleApp)"

Note

This launches a simple development server which is good enough for testing, but probably not what you want to use in production. When deploying in production, there’s a number of different ways of running ReactPy.

You should then see a few log messages:

2022-03-27T11:58:59-0700 | WARNING | You are running a development server. Change this before deploying in production!
2022-03-27T11:58:59-0700 | INFO | Running with 'Starlette' at http://127.0.0.1:8000

The second log message includes a URL indicating where you should go to view the app. That will usually be http://127.0.0.1:8000. Once you go to that URL you should see something like this:

If you get a RuntimeError similar to the following:

Found none of the following builtin server implementations...

Then be sure you run pip install "reactpy[starlette]" instead of just reactpy. For anything else, report your issue in ReactPy’s discussion forum.

Read More

Learn how ReactPy can be installed in a variety of different ways - with different web servers and even in different frameworks.

Section 2: Running ReactPy#

Once you’ve installed ReactPy, you’ll want to learn how to run an application. Throughout most of the examples in this documentation, you’ll see the run() function used. While it’s convenient tool for development it shouldn’t be used in production settings - it’s slow, and could leak secrets through debug log messages.

from reactpy import component, html, run


@component
def App():
    return html.h1("Hello, world!")


run(App)

Read More

See how ReactPy can be run with a variety of different production servers or be added to existing applications.