Skip to main content

PythonNative

Build native Android and iOS apps in Python.

CI Release PyPI Version Python Versions License: MIT Docs

Documentation · Getting Started · Examples · Contributing


Overview

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.

Features

  • Declarative UI: Describe what your UI should look like with element functions (Text, Button, Column, Row, etc.). PythonNative creates and updates native views automatically.
  • Rich component library: 25+ built-in components backed by real native widgets: TextInput, Image / ImageBackground, ScrollView, FlatList / SectionList, Modal, Pressable / TouchableOpacity, Switch / Checkbox, Slider, SegmentedControl, Picker, DatePicker, ProgressBar / ActivityIndicator, WebView, and more.
  • Device APIs: Cross-platform modules for Camera, Location, FileSystem, Notifications, Clipboard, Share, Linking, Permissions, AppState, NetInfo, SecureStore, Battery, Haptics / Vibration, and Biometrics, plus reactive use_app_state and use_net_info hooks.
  • Hooks and function components: Manage state with use_state, side effects with use_effect / use_layout_effect, refs and imperative handles with use_ref / use_imperative_handle, and navigation with use_navigation, all through one consistent pattern. Components can return a single element, a list of siblings, or None, and Fragment, Portal, and reactive Provider context work the way they do in React.
  • Async-first rendering: One asyncio event loop runs the whole framework on the platform's main thread. Components can be async def and await data directly in the body; Suspense boundaries show declarative loading states while they wait. use_resource fetches during render, use_effect accepts coroutine callbacks (cancelled automatically on unmount), lazy code-splits components, and use_transition / use_deferred_value keep the UI responsive during expensive updates.
  • Developer feedback that finds your bugs: In dev mode (pn preview, hot reload, or PN_DEV=1), uncaught errors from renders, effects, and event handlers show a full-screen RedBox with the traceback; unknown style keys and duplicate list keys print "did you mean" warnings; and conditional hooks raise a HookOrderError at the source instead of silently cross-wiring state.
  • Typed style prop: Pass all visual and layout properties through a single style dict, fully described by the pn.Style TypedDict and the ergonomic pn.style(...) helper for IDE autocomplete and static checking. Compose reusable styles with StyleSheet.
  • 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, and position: "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. Each commit lands as one batched transaction of mutation ops, and event callbacks are routed through a tag-based registry so re-renders that only change closures cost zero native calls. State updates re-render locally: only the component whose state changed (and its subtree) re-runs, and unchanged leaves reuse cached intrinsic measurements, so deep UIs stay responsive instead of re-rendering the whole app from the root on every tap.
  • Native-driven animations: The Animated API (timing / spring / decay / loop / stagger, awaitable or fire-and-forget) hands animations to Core Animation and ViewPropertyAnimator whenever possible, so no Python code runs per frame; a pure-Python ticker covers the rest. interpolate, arithmetic operators on animated nodes, Animated.event scroll binding, and diff_clamp cover the scroll-driven patterns (collapsing headers, parallax) that define native feel.
  • Native gesture system: Attach Tap, LongPress, Pan, Swipe, Fling, Pinch, and Rotation recognizers to any view via the gestures= prop, backed by UIGestureRecognizer on iOS and a unit-testable pure-Python arbiter on Android and desktop. Compose them with Race, Exclusive, and Simultaneous for cross-gesture arbitration (single vs. double tap, drag vs. long press).
  • Virtualized lists: FlatList / SectionList window their rows in Python over the platform scroll view: uniform, exact, or measured variable heights, grids, headers/footers, infinite scroll, and an imperative scroll controller, identical on every platform.
  • Direct native bindings: Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
  • Custom-component SDK: Wrap any platform widget as a first-class element with type-checked props via pythonnative.sdk (Props, @native_component, element_factory). Plugins distributed on PyPI auto-register through the pythonnative.handlers entry-point group.
  • CLI scaffolding: pn init creates a ready-to-run project; pn run android and pn run ios build and launch your app.
  • Instant desktop preview: pn preview renders your app in a native desktop window via Tkinter with Fast Refresh on every save: iterate on layout, state, and navigation in milliseconds without booting a simulator or device. The reconciler, hooks, layout engine, and navigation are the same code that ships to the phone.
  • Native-backed navigation: Declarative Stack, Tab, and Drawer navigators inspired by React Navigation. The root stack drives the platform's native navigation controller (UINavigationController on iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect; use_back_handler intercepts the back action when a screen needs to.
  • Fast Refresh hot reload: pn run --hot-reload watches app/ 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.

Quick Start

Installation

pip install pythonnative

Usage

import pythonnative as pn


@pn.component
def App():
    count, set_count = pn.use_state(0)
    return pn.Column(
        pn.Text(f"Count: {count}", style=pn.style(font_size=24, bold=True)),
        pn.Button(
            "Tap me",
            on_press=lambda: set_count(count + 1),
        ),
        style=pn.style(spacing=12, padding=16),
    )

Documentation

Visit pythonnative.com for the full documentation, including getting started guides, platform-specific instructions for Android and iOS, API reference, and working examples.

Contributing

Contributions are welcome. Please see CONTRIBUTING.md for setup instructions, coding standards, and guidelines for submitting pull requests.

License

MIT

Metadata

Release files for pythonnative 0.29.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pythonnative 0.29.0
File Size Uploaded
pythonnative-0.29.0.tar.gz 597.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pythonnative 0.29.0
File Interpreter ABI Platform
pythonnative-0.29.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / pythonnative-0.29.0.tar.gz

Download URL pythonnative-0.29.0.tar.gz
Size 597.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9cdff1b168b0dd756aa84c975dd75fd555f10373d1012e14b0c5417f8dc9029a
BLAKE2b-256 checksum
How to use checksums
8234b75ed618f9599c8d1651cb02a97bd9758c485007c0fd0f9105c576b76263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / pythonnative-0.29.0-py3-none-any.whl

Download URL pythonnative-0.29.0-py3-none-any.whl
Size 548.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae5fb3eba09cfd3057c9abd76e882562fcbb3551e1929a923ae709cb36ee322d
BLAKE2b-256 checksum
How to use checksums
a350945b5e41a4b92361d9472f668c0e5f1eee9eabd2719bc1853baac744fd4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.31.0

2 release files

0.30.0

2 release files

This release

0.29.0 This release

2 release files

0.28.0

2 release files

0.27.0

2 release files

0.26.0

2 release files

0.25.0

2 release files

0.24.0

2 release files

0.22.1

2 release files

0.22.0

2 release files

0.18.0

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page