For AI agents: the complete documentation index is at llms.txt. Markdown versions are available by appending .md or sending Accept: text/markdown.
Reflex Logo
Docs Logo
Api Reference

/

App

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.

Attributes: theme: Deprecated legacy shortcut for configuring the app-level Radix theme. style: The global style for the app. stylesheets: A list of URLs to stylesheets to include in the app. reset_style: Whether to include CSS reset for margin and padding. Defaults to True. app_wraps: 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: Extra app wraps to be applied to the whole app. head_components: Components to add to the head of every page. sio: The Socket.IO AsyncServer instance. html_lang: The language to add to the html root tag of every page. html_custom_attrs: Attributes to add to the html root tag of every page. enable_state: Whether to enable state for the app. If False, the app will not use state. admin_dash: Admin dashboard to view and manage the database. frontend_exception_handler: Frontend error handler function. backend_exception_handler: Backend error handler function. toaster: Put the toast provider in the app wrap. api_transformer: Transform the ASGI app before running it.

Fields

PropDescription
theme: reflex_base.components.component.Component | None = None

Deprecated legacy shortcut for configuring the app-level Radix theme.

style: dict[str | type[reflex_base.components.component.BaseComponent] | collections.abc.Callable | reflex_base.components.component.ComponentNamespace, typing.Any] = <class 'dict'>

The global style for the app.

stylesheets: list[str] = <class 'list'>

A list of URLs to stylesheets to include in the app.

reset_style: bool = True

Whether to include CSS reset for margin and padding. Defaults to True.

app_wraps: dict[tuple[int, str], collections.abc.Callable[[bool], reflex_base.components.component.Component | None]] = <function App.<lambda> at 0x7fe87ae1ab60>

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], collections.abc.Callable[[bool], reflex_base.components.component.Component | None]] = <class 'dict'>

Extra app wraps to be applied to the whole app.

head_components: list[reflex_base.components.component.Component] = <class 'list'>

Components to add to the head of every page.

sio: socketio.async_server.AsyncServer | None = None

The Socket.IO AsyncServer instance.

html_lang: str | None = None

The language to add to the html root tag of every page.

html_custom_attrs: dict[str, str] | None = None

Attributes to add to the html root tag of every page.

enable_state: bool = True

Whether to enable state for the app. If False, the app will not use state.

admin_dash: reflex.admin.AdminDash | None = None

Admin dashboard to view and manage the database.

frontend_exception_handler: collections.abc.Callable[[Exception], None] = <function default_frontend_exception_handler at 0x7fe87b96b380>

Frontend error handler function.

backend_exception_handler: collections.abc.Callable[[Exception], reflex_base.event.EventSpec | list[reflex_base.event.EventSpec] | None] = <function default_backend_exception_handler at 0x7fe88935e520>

Backend error handler function.

toaster: reflex_base.components.component.Component | None = <bound method Toaster.create of <class 'reflex_components_sonner.toast.Toaster'>>

Put the toast provider in the app wrap.

api_transformer: collections.abc.Sequence[collections.abc.Callable[[collections.abc.Callable[[typing.MutableMapping[str, typing.Any], collections.abc.Callable[[], typing.Awaitable[typing.MutableMapping[str, typing.Any]]], collections.abc.Callable[[typing.MutableMapping[str, typing.Any]], typing.Awaitable[NoneType]]], typing.Awaitable[NoneType]]], collections.abc.Callable[[typing.MutableMapping[str, typing.Any], collections.abc.Callable[[], typing.Awaitable[typing.MutableMapping[str, typing.Any]]], collections.abc.Callable[[typing.MutableMapping[str, typing.Any]], typing.Awaitable[NoneType]]], typing.Awaitable[NoneType]]] | starlette.applications.Starlette] | collections.abc.Callable[[collections.abc.Callable[[typing.MutableMapping[str, typing.Any], collections.abc.Callable[[], typing.Awaitable[typing.MutableMapping[str, typing.Any]]], collections.abc.Callable[[typing.MutableMapping[str, typing.Any]], typing.Awaitable[NoneType]]], typing.Awaitable[NoneType]]], collections.abc.Callable[[typing.MutableMapping[str, typing.Any], collections.abc.Callable[[], typing.Awaitable[typing.MutableMapping[str, typing.Any]]], collections.abc.Callable[[typing.MutableMapping[str, typing.Any]], typing.Awaitable[NoneType]]], typing.Awaitable[NoneType]]] | starlette.applications.Starlette | None = None

Transform the ASGI app before running it.

Methods

SignatureDescription
frontend_exception_handler(exception: 'Exception') -> 'None'Default frontend exception handler function.
backend_exception_handler(exception: 'Exception') -> 'EventSpec'Default backend exception handler function.
set_contexts(self) -> 'contextlib.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(self, component: 'Component | ComponentCallable | None' = None, route: 'str | None' = None, title: 'str | Var | None' = None, description: 'str | Var | None' = None, image: 'str' = 'favicon.ico', on_load: 'EventType[()] | None' = None, meta: 'Sequence[Mapping[str, Any] | Component]' = [], context: 'dict[str, Any] | None' = 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(self, path: 'str') -> 'list[IndividualEventType[()]]'Get the load events for a route.
add_all_routes_endpoint(self)Add an endpoint to the app that returns all the routes.
modify_state(self, token: 'BaseStateToken | str', background: 'bool' = False, previous_dirty_vars: 'dict[str, set[str]] | None' = None, **context: 'Unpack[StateModificationContext]') -> 'AsyncIterator[BaseState]'Modify the state out of band.
Built with Reflex