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: The global theme for the entire app. 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. overlay_component: A component that is present on every page. Defaults to the Connection Error banner. 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
lifespan_tasks: set[_asyncio.Task | collections.abc.Callable] = <class 'set'>
theme: reflex.components.component.Component | None = <function App.<lambda> at 0x7f463bc79f80>

The global theme for the entire app.

style: dict[str | type[reflex.components.component.BaseComponent] | collections.abc.Callable | reflex.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.

overlay_component: reflex.components.component.Component | collections.abc.Callable[[], reflex.components.component.Component | tuple[reflex.components.component.Component, ...] | str] | None = None

A component that is present on every page. Defaults to the Connection Error banner.

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

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.components.component.Component | None]] = <class 'dict'>

Extra app wraps to be applied to the whole app.

head_components: list[reflex.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 0x7f4641cd9120>

Frontend error handler function.

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

Backend error handler function.

toaster: reflex.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.
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: '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