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.
Fields
Prop | Description |
---|---|
theme: Component | None | The global theme for the entire app. |
style: ComponentStyle | The global style for the app. |
stylesheets: list[str] | 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: Component | ComponentCallable | None = None | A component that is present on every page (defaults to the Connection Error banner). |
app_wraps: dict[tuple[int, str], Callable[[bool], Component | None]] | 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], Component | None]] | Extra app wraps to be applied to the whole app. |
head_components: list[Component] | Components to add to the head of every page. |
sio: 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: AdminDash | None = None | Admin dashboard to view and manage the database. |
frontend_exception_handler: Callable[[Exception], None] = <function default_frontend_exception_handler at 0x7f5737d23420> | Frontend Error Handler Function |
backend_exception_handler: Callable[[Exception], EventSpec | list[EventSpec] | None] = <function default_backend_exception_handler at 0x7f573652ac00> | Backend Error Handler Function |
toaster: Component | None | Put the toast provider in the app wrap. |
api_transformer: Sequence[Callable[[ASGIApp], ASGIApp] | Starlette] | Callable[[ASGIApp], ASGIApp] | Starlette | None = None | Transform the ASGI app before running it. |
Methods
Signature | Description |
---|---|
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: 'list[dict[str, str]]' = [], 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') -> 'AsyncIterator[BaseState]' | Modify the state out of band. |