MCPcopy
hub / github.com/reflex-dev/reflex / App

Class App

reflex/app.py:312–1531  ·  view source on GitHub ↗

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={...}, #

Source from the content-addressed store, hash-verified

310
311@dataclasses.dataclass()
312class App(MiddlewareMixin, LifespanMixin):
313 """The main Reflex app that encapsulates the backend and frontend.
314
315 Every Reflex app needs an app defined in its main module.
316
317 ```python
318 # app.py
319 import reflex as rx
320
321 # Define state and pages
322 ...
323
324 app = rx.App(
325 # Set global level style.
326 style={...},
327 # Deprecated legacy shortcut for the Radix Themes plugin.
328 theme=rx.theme(accent_color="blue"),
329 )
330 ```
331
332 Attributes:
333 theme: Deprecated legacy shortcut for configuring the app-level Radix [theme](https://reflex.dev/docs/styling/theming/).
334 style: The [global style](https://reflex.dev/docs/styling/overview/#global-styles) for the app.
335 stylesheets: A list of URLs to [stylesheets](https://reflex.dev/docs/styling/custom-stylesheets/) to include in the app.
336 reset_style: Whether to include CSS reset for margin and padding. Defaults to True.
337 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.
338 extra_app_wraps: Extra app wraps to be applied to the whole app.
339 head_components: Components to add to the head of every page.
340 sio: The Socket.IO AsyncServer instance.
341 html_lang: The language to add to the html root tag of every page.
342 html_custom_attrs: Attributes to add to the html root tag of every page.
343 enable_state: Whether to enable [state](https://reflex.dev/docs/state/overview/) for the app. If False, the app will not use state.
344 admin_dash: Admin dashboard to view and manage the database.
345 frontend_exception_handler: Frontend [error handler](https://reflex.dev/docs/utility-methods/exception-handlers/) function.
346 backend_exception_handler: Backend [error handler](https://reflex.dev/docs/utility-methods/exception-handlers/) function.
347 toaster: Put the [toast](https://reflex.dev/docs/library/overlay/toast/) provider in the app wrap.
348 api_transformer: 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.
349 """
350
351 theme: Component | None = dataclasses.field(default=None)
352
353 style: ComponentStyle = dataclasses.field(default_factory=dict)
354
355 stylesheets: list[str] = dataclasses.field(default_factory=list)
356
357 reset_style: bool = dataclasses.field(default=True)
358
359 app_wraps: dict[tuple[int, str], Callable[[bool], Component | None]] = (
360 dataclasses.field(
361 default_factory=lambda: {
362 (55, "ErrorBoundary"): (
363 lambda stateful: default_error_boundary(
364 **({"on_error": noop()} if not stateful else {})
365 )
366 ),
367 (5, "Overlay"): (
368 lambda stateful: default_overlay_component() if stateful else None
369 ),

Calls 4

noopFunction · 0.90
default_error_boundaryFunction · 0.85
extra_overlay_functionFunction · 0.85