Solara
Solara is an open-source Python library designed to simplify building reactive web applications using ipywidgets and a React-like API. It allows developers to create sophisticated data apps that run seamlessly both within Jupyter Notebooks and as standalone web applications, leveraging frameworks like FastAPI or Starlette. Solara is currently on version 1.57.3 and maintains an active release cadence with frequent updates and bug fixes.
Common errors
-
ModuleNotFoundError: No module named 'solara'
cause The Solara library has not been installed in the current Python environment.fixRun `pip install solara` to install the library. -
RuntimeError in BaseSettings iteration
cause This error can occur in Solara versions prior to 1.55.0 when running with Python 3.14 due to compatibility issues with `BaseSettings`.fixUpgrade Solara to version 1.55.0 or higher. `pip install --upgrade solara` -
Solara app not rendering in Jupyter Notebook
cause The main component function (e.g., `Page`) was not explicitly called at the end of the Jupyter cell.fixAdd `Page()` at the end of the Jupyter Notebook cell to render the Solara application.
Warnings
- breaking Solara dropped support for Python 3.7. Applications running on Python 3.7 will not be compatible with Solara versions 1.56.0 and higher.
- gotcha When defining state, `solara.reactive()` creates global, per-session state, while `solara.use_state()` creates component-specific local state. Using `solara.reactive()` for local component state can lead to unexpected behavior across multiple instances of the same component.
- gotcha When running Solara applications directly in a Jupyter Notebook cell, you must explicitly call the main `@solara.component` (typically `Page`) at the end of the cell (e.g., `Page()`) for it to render. This is not necessary when running with `solara run`.
- breaking A security fix (CVE-2026-24008) for a path traversal vulnerability in `path_is_child_of` was implemented. Older versions may be vulnerable.
- gotcha Solara server in Docker environments may fail to start if the `$HOME` environment variable is not set or points to a non-writable directory, even if a bug fix for this was implemented in v1.50.1.
Install
-
pip install solara
Imports
- solara
import solara
Quickstart
import solara
sentence = solara.reactive("Solara makes our team more productive.")
word_limit = solara.reactive(10)
@solara.component
def Page():
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)
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!")
# To run this in a .py file from the command line: `solara run your_app.py`
# To run this in a Jupyter Notebook cell, add the following line at the end:
# Page()