Build native Android and iOS apps in Python.
Documentation · Getting Started · Examples · Contributing
PythonNative is a cross-platform toolkit for building native Android and iOS apps in Python. It provides a declarative, React-like component model with hooks and automatic reconciliation, powered by Chaquopy on Android and rubicon-objc on iOS. Write function components with use_state, use_effect, and friends, just like React, and let PythonNative handle creating and updating native views.
- Declarative UI: Describe what your UI should look like with element functions (
Text,Button,Column,Row, etc.). PythonNative creates and updates native views automatically. - Hooks and function components: Manage state with
use_state, side effects withuse_effect, and navigation withuse_navigation, all through one consistent pattern. styleprop: Pass all visual and layout properties through a singlestyledict, composable viaStyleSheet.- Cross-platform flexbox engine: A pure-Python, Yoga-style layout engine computes frames once and applies them to native views, so
flex,padding,aspect_ratio, andposition: "absolute"produce the same geometry on Android and iOS. - Virtual view tree + reconciler: Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation.
- Direct native bindings: Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
- CLI scaffolding:
pn initcreates a ready-to-run project;pn run androidandpn run iosbuild and launch your app. - Native-backed navigation: Declarative
Stack,Tab, andDrawernavigators inspired by React Navigation. The root stack drives the platform's native navigation controller (UINavigationControlleron iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect. - Fast Refresh hot reload:
pn run --hot-reloadwatchesapp/and patches edits into the running app on save, preserving component state across most changes. - Bundled templates: Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.
pip install pythonnativeimport pythonnative as pn
@pn.component
def App():
count, set_count = pn.use_state(0)
return pn.Column(
pn.Text(f"Count: {count}", style={"font_size": 24}),
pn.Button(
"Tap me",
on_click=lambda: set_count(count + 1),
),
style={"spacing": 12, "padding": 16},
)Visit docs.pythonnative.com for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.
Contributions are welcome. Please see CONTRIBUTING.md for setup instructions, coding standards, and guidelines for submitting pull requests.
