# Solara

> Build data apps in pure Python with a React-style component API

- Category: App UIs & Builders / Data App Builders
- Language: Python
- Licence: MIT
- Repository: https://github.com/widgetti/solara
- Website: https://solara.dev
- Canonical page: https://ai-tldr.dev/tools/solara/

## In short

Solara is a Python framework for building data apps using a React-like, component-based API. It uses a pure-Python implementation of React called Reacton to create ipywidget-based interfaces, so the same code runs inside a Jupyter notebook and as a standalone web app served by Starlette/FastAPI. It sits in the Data App Builders category of the App UIs & Builders tools and is open-source, written in Python and licensed MIT.

## Overview

Solara is a Python framework for building data apps using a React-like, component-based API. It uses a pure-Python implementation of React called Reacton to create ipywidget-based interfaces, so the same code runs inside a Jupyter notebook and as a standalone web app served by Starlette/FastAPI.

It targets data scientists and Python developers who want their apps to stay maintainable as they grow. Instead of letting state and code organization turn into spaghetti, you write reusable components and manage state with reactive variables that re-run the components that depend on them.

As a data app builder, Solara fits alongside tools like Streamlit and Dash, but leans on the React model and the existing ipywidgets ecosystem. That lets it run on JupyterLab, Jupyter Notebook, Voila, Google Colab, Databricks, JetBrains Datalore, and more without rewriting your app.

## What it does

- React-style components written entirely in Python, no JavaScript required
- Reactive variables (solara.reactive) that re-execute the components using them when values change
- Runs the same code in Jupyter notebooks and as a standalone web app
- Built on ipywidgets, so it works across JupyterLab, Voila, Google Colab, Databricks, and Datalore
- Standalone server built on Starlette/FastAPI, suitable for production
- Hot code reloading and type hints for faster development

## Getting started

Install Solara with pip, write a small component in a Python file, then run it with the solara CLI.

1. Install Solara

   Install the package from PyPI.

```bash
pip install solara
```

2. Write a first script

   Put this snippet in a file named sol.py. It declares reactive variables at the top level and a Page component that updates as those values change.

```python
import solara

# Declare reactive variables at the top level. Components using these variables
# will be re-executed when their values change.
sentence = solara.reactive("Solara makes our team more productive.")
word_limit = solara.reactive(10)

@solara.component
def Page():
    # Calculate word_count within the component to ensure re-execution when reactive variables change.
    word_count = len(sentence.value.split())

    solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
    solara.InputText(label="Your sentence", value=sentence, continuous_update=True)

    # Display messages based on the current word count and word limit.
    if word_count >= int(word_limit.value):
        solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
    elif word_count >= int(0.8 * word_limit.value):
        solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
    else:
        solara.Success("Great short writing!")

# The following line is required only when running the code in a Jupyter notebook:
Page()
```

3. Run it

   From the same directory as sol.py, start the Solara server. It serves the app at http://localhost:8765. Alternatively, paste the snippet into a Jupyter notebook cell and run it; the Page() call renders the component inline.

```bash
solara run sol.py
```

## When to use it

- Turn a Jupyter notebook analysis into an interactive web app without rewriting it
- Build internal data dashboards and exploration tools, such as a scatter plot that filters and downloads a dataset
- Ship a Python data app to production behind a FastAPI/Starlette server
- Create reusable, component-based UIs that stay maintainable as the app grows
