Overview
Page is a container for View controls. A page instance and the root view are automatically created when a new user session starts. Source:flet.controls.page:344
Class Signature
Properties
Session and Connection
The session that this page belongs to. Read-only property.Source:
page.py:1106The query parameters of the current page. Read-only property.Source:
page.py:1115The URL of the current page. Read-only property.Source:
page.py:1122The name of the current page. Read-only property.Source:
page.py:1129The event loop for the current page. Read-only property.Source:
page.py:1136The executor for the current page. Read-only property.Source:
page.py:1143Page State
Gets current app route. Read-only property.Source:
page.py:369True if the application is running in the web browser. Read-only property.Source: page.py:377True if the application is running as Progressive Web App (PWA). Read-only property.Source: page.py:385True if Flutter client of Flet app is running in debug mode. Read-only property.Source: page.py:392True if the application is running in WebAssembly (WASM) mode. Read-only property.Source: page.py:400True if the application is running with test mode. Read-only property.Source: page.py:408True if the application is running with multi-view support. Read-only property.Source: page.py:416True if the application is running in Pyodide (WebAssembly) mode. Read-only property.Source: page.py:424Platform and Device
The operating system the application is running on.Source:
page.py:456The current brightness mode of the host platform. Read-only property.Source:
page.py:432IP address of the connected user. Web-only, read-only property.Source:
page.py:440Browser details of the connected user. Web-only, read-only property.Source:
page.py:448Multi-View
The list of multi-views associated with this page.Source:
page.py:358Provides properties/methods/events to monitor and control the app’s native OS window.Source:
page.py:363Customization
Defines the custom fonts to be used in the application.Value is a dictionary where:
- Key: The font family name used for reference
- Value: The font source (absolute URL or relative path to local asset)
.ttc, .ttf, .otfSource: page.py:461Authentication
The current authorization context, or
None if the user is not authorized. Read-only property.Source: page.py:1150The PubSub client for the current page. Read-only property.Source:
page.py:1157Events
Navigation Events
Called when page route changes either programmatically, by editing application URL or using browser Back/Forward buttons.Source:
page.py:497Called when the user clicks automatic “Back” button in AppBar control.Source:
page.py:503Platform Events
Called when brightness of app host platform has changed.Source:
page.py:475Called when the locale preferences/settings of the host platform have changed. For example, when the user updates device language settings or browser preferred languages.Source:
page.py:482Called when app lifecycle state changes.Source:
page.py:490Input Events
Called when a keyboard key is pressed.Source:
page.py:508Connection Events
Called when a web user (re-)connects to a page session. Not triggered when an app page is first opened, but triggered when the page is refreshed or Flet web client has re-connected.Source:
page.py:513Called when a web user disconnects from a page session, i.e., closes browser tab/window.Source:
page.py:523Called when a session has expired after configured amount of time (60 minutes by default).Source:
page.py:529Called when unhandled exception occurs.Source:
page.py:548Authentication Events
Called upon successful or failed OAuth authorization flow.Source:
page.py:535Called after
page.logout() call.Source: page.py:543Multi-View Events
Called when a new multi-view is created.Source:
page.py:553Called when a multi-view is removed.Source:
page.py:558Methods
Control Management
Get a control by its internal ID.Source:
page.py:576Parameters:id(int): Internal control ID
None if not foundPush pending state changes to the client.Source:
page.py:655Parameters:*controls: Specific controls to patch. When omitted, patches the whole page state.
Report an application error to the current session/client.Source:
page.py:691Parameters:message(str): Error message to send
Component Rendering
render
(component: Callable[..., Union[list[View], View, list[Control], Control]], *args, **kwargs) -> None
Render a component tree into controls of the root view. The rendered result replaces
page.views[0].controls.Source: page.py:590Parameters:component: Component function to render*args: Positional arguments passed to component**kwargs: Keyword arguments passed to component
render_views
(component: Callable[..., Union[list[View], View, list[Control], Control]], *args, **kwargs) -> None
Render a component tree as the full list of page views. The rendered result replaces
page.views.Source: page.py:613Parameters:component: Component function to render*args: Positional arguments passed to component**kwargs: Keyword arguments passed to component
Queue this page for a deferred batched update.Source:
page.py:648Threading and Async
Run handler coroutine as a new Task in the event loop associated with the current page.Source:
page.py:717Parameters:handler: Coroutine function to run*args: Positional arguments for handler**kwargs: Keyword arguments for handler
TypeError: If handler is not a coroutine function
Run handler function as a new Thread in the executor associated with the current page.Source:
page.py:779Parameters:handler: Function to run in thread*args: Positional arguments for handler**kwargs: Keyword arguments for handler
Navigation
Pushes a new navigation route to the browser history stack. Changing route will fire
page.on_route_change event handler.Source: page.py:817Parameters:route(str): New navigation route**kwargs: Additional query string parameters to be added to the route
Upload
Generates presigned upload URL for built-in upload storage.Source: To enable built-in upload storage, provide
page.py:898Parameters:file_name(str): Relative path to upload storageexpires(int): URL time-to-live in seconds
upload_dir to ft.run():Authentication
login
async (provider: OAuthProvider, fetch_user: bool = True, fetch_groups: bool = False, scope: Optional[list[str]] = None, saved_token: Optional[str] = None, on_open_authorization_url: Optional[Callable[[str], Coroutine]] = None, complete_page_html: Optional[str] = None, redirect_to_page: Optional[bool] = False, authorization: type[AT] = AuthorizationImpl) -> AT
Starts OAuth flow.Source:
page.py:919Parameters:provider(OAuthProvider): OAuth provider configurationfetch_user(bool): Whether to fetch user informationfetch_groups(bool): Whether to fetch user groupsscope(Optional[list[str]]): OAuth scopes to requestsaved_token(Optional[str]): Previously saved token to rehydrateon_open_authorization_url(Optional[Callable]): Custom handler for authorization URLcomplete_page_html(Optional[str]): Custom HTML for completion pageredirect_to_page(Optional[bool]): Redirect back to page after authauthorization(type[AT]): Authorization implementation class
Clears current authentication context.Source:
page.py:1016Device Information
Returns device information.Source:
page.py:1213Returns: Device information object for the current platform, or None if unavailableReturn types:WebDeviceInfofor webAndroidDeviceInfofor AndroidIosDeviceInfofor iOSMacOsDeviceInfofor macOSLinuxDeviceInfofor LinuxWindowsDeviceInfofor Windows
Constrains the allowed orientations for the app when running on a mobile device.Source:
page.py:1238Parameters:orientations(list[DeviceOrientation]): List of allowed device orientations. Set to empty list to use system default.
FletUnsupportedPlatformException: If called on non-mobile platform
- Android: On Android 16+ with displays ≥600dp width, orientation cannot be changed. Android limits orientation combinations.
- iOS: Only respected on iPad if multitasking is disabled
Deprecated Methods
DEPRECATED: Use
push_route() instead.Deprecated in version 0.80.0, will be removed in 0.90.0.Source: page.py:800launch_url
async (url: Union[str, Url], *, web_popup_window_name: Optional[Union[str, UrlTarget]] = None, web_popup_window: bool = False, web_popup_window_width: Optional[int] = None, web_popup_window_height: Optional[int] = None) -> None
DEPRECATED: Use
UrlLauncher().launch_url() instead.Deprecated in version 0.90.0.Source: page.py:1032DEPRECATED: Use
UrlLauncher().can_launch_url() instead.Deprecated in version 0.90.0.Source: page.py:1070DEPRECATED: Use
UrlLauncher().close_in_app_web_view() instead.Deprecated in version 0.90.0.Source: page.py:1097Usage Examples
Basic Page Setup
Navigation with Routes
Using Threading
OAuth Authentication
See Also
- BasePage - Base class for Page
- [View(/api/page) - View component for navigation
- Control - Base control class
- app() and run() - App lifecycle functions