> For AI agents: the complete documentation index is at [llms.txt](https://reflex.dev/docs/llms.txt). Markdown versions are available by appending `.md` or sending `Accept: text/markdown`.

# App

`reflex.app.App`

The main Reflex app that encapsulates the backend and frontend.

Every Reflex app needs an app defined in its main module.

```python
# app.py
import reflex as rx

# Define state and pages
...

app = rx.App(
    # Set global level style.
    style={...},
    # Deprecated legacy shortcut for the Radix Themes plugin.
    theme=rx.theme(accent_color="blue"),
)
```

## Fields

| Prop | Description |
| --- | --- |
| `theme: Optional[Component]` | Deprecated legacy shortcut for configuring the app-level Radix [theme](https://reflex.dev/docs/styling/theming/). |
| `style: dict[str \| type[BaseComponent] \| Callable \| ComponentNamespace, Any]` | The [global style](https://reflex.dev/docs/styling/overview/#global-styles) for the app. |
| `stylesheets: list[str]` | A list of URLs to [stylesheets](https://reflex.dev/docs/styling/custom-stylesheets/) to include in the app. |
| `reset_style: bool` | Whether to include CSS reset for margin and padding. Defaults to True. |
| `app_wraps: dict[tuple[int, str], Callable[[bool], Optional[Component]]]` | App wraps to be applied to the whole app. Expected to be a dictionary of (order, name) to a function that takes whether the state is enabled and optionally returns a component. |
| `extra_app_wraps: dict[tuple[int, str], Callable[[bool], Optional[Component]]]` | Extra app wraps to be applied to the whole app. |
| `head_components: list[Component]` | Components to add to the head of every page. |
| `sio: Optional[AsyncServer]` | The Socket.IO AsyncServer instance. |
| `html_lang: Optional[str]` | The language to add to the html root tag of every page. |
| `html_custom_attrs: Optional[dict[str, str]]` | Attributes to add to the html root tag of every page. |
| `enable_state: bool` | Whether to enable [state](https://reflex.dev/docs/state/overview/) for the app. If False, the app will not use state. |
| `admin_dash: Optional[AdminDash]` | Admin dashboard to view and manage the database. |
| `frontend_exception_handler: Callable[[Exception], None]` | Frontend [error handler](https://reflex.dev/docs/utility-methods/exception-handlers/) function. |
| `backend_exception_handler: Callable[[Exception], Optional[EventSpec \| list[EventSpec]]]` | Backend [error handler](https://reflex.dev/docs/utility-methods/exception-handlers/) function. |
| `toaster: Optional[Component]` | Put the [toast](https://reflex.dev/docs/library/overlay/toast/) provider in the app wrap. |
| `hydrate_fallback: Optional[Component \| Callable[[], Component \| tuple[Component, Ellipsis] \| str]]` |  |
| `api_transformer: Optional[Sequence[Callable[[ASGIApp], ASGIApp] \| Starlette] \| Callable[[ASGIApp], ASGIApp] \| Starlette]` | One or more transforms applied to the backend ASGI app before it runs — mount a FastAPI/Starlette app or wrap it in ASGI middleware. See the [API Transformer docs](https://reflex.dev/docs/api-routes/overview/) for examples. |

## Methods

| Signature | Description |
| --- | --- |
| `set_contexts() -> AbstractContextManager` | Set Reflex contexts needed for state and event processing.  Pushes RegistrationContext and EventContext into the current contextvars scope, but only if they are not already set.  Can be used as a context manager::      with app.set_contexts():         async with app.modify_state(token) as state:             ... |
| `add_page(component: Optional[Component \| ComponentCallable] = None, route: Optional[str] = None, title: Optional[str \| Var] = None, description: Optional[str \| Var] = None, image: str = 'favicon.ico', on_load: Optional[EventType[()]] = None, meta: Sequence[Mapping[str, Any] \| Component] = [], context: Optional[dict[str, Any]] = None)` | Add a page to the app.  If the component is a callable, by default the route is the name of the function. Otherwise, a route must be provided. |
| `get_load_events(path: str) -> list[IndividualEventType[()]]` | Get the load events for a route. |
| `add_all_routes_endpoint()` | Add an endpoint to the app that returns all the routes. |
| `modify_state(token: BaseStateToken \| str, background: bool = False, previous_dirty_vars: Optional[dict[str, set[str]]] = None, **context: Unpack[StateModificationContext]) -> AsyncIterator[BaseState]` | Modify the state out of band. |
