Skip to content

Quick Start

aaalllexxx edited this page Jun 29, 2026 · 1 revision

Quick Start

This walks you from zero to a running app, then to an installable APK.

1. Create a project

paf create myapp
cd myapp

This scaffolds:

myapp/
├── enpaf.json        # project config (name, package, permissions, ...)
├── main.py           # Python entry point
└── app/              # your web UI
    ├── index.html
    ├── css/style.css
    └── js/app.js

You can choose the Android package name up front:

paf create myapp --package com.acme.myapp

If omitted, the package defaults to com.enpaf.<name>.

2. Run it in the browser

paf run

Open http://127.0.0.1:8080. The dev server (Flask + Socket.IO) serves your app/ folder, injects the ENPAF JS bridge, and live-reloads on changes. A settings panel is available at /enpaf-settings.

Useful flags:

paf run --port 3000        # custom port
paf run --no-browser       # don't auto-open the browser
paf run --debug            # verbose / debug mode

3. Write some Python ↔ JS

main.py

from enpaf import EnpafApp

app = EnpafApp(__name__)

@app.route("/")
def index():
    return app.render("index.html", title=app.name)

@app.bridge_handler("add")
def add(params):
    return {"sum": float(params.get("a", 0)) + float(params.get("b", 0))}

@app.on("app_start")
def on_start():
    print("App started!")

if __name__ == "__main__":
    app.run()

app/js/app.js

async function calc() {
  const res = await enpaf.call("add", { a: 2, b: 3 });
  enpaf.device.toast("2 + 3 = " + res.sum);
}

enpaf.ready(() => console.log("bridge ready"));

The enpaf object is injected automatically — no <script> import needed for the bridge itself (ENPAF adds it into your <head>).

4. Persist data

@app.bridge_handler("save_note")
def save_note(params):
    notes = app.storage.collection("notes")
    return {"id": notes.add({"text": params["text"]})}

@app.bridge_handler("get_notes")
def get_notes(params):
    return {"notes": app.storage.collection("notes").all()}

Storage is SQLite-backed and works identically in dev and on-device. See Storage.

5. Build an APK

Make sure the build toolchain is installed, then:

paf build apk            # debug build (auto-signed, installable)
paf build apk --release  # release build (signed, optimized)

The APK lands in dist/<name>-<version>.apk. Install it:

adb install dist/myapp-1.0.0.apk

…or transfer the file to your phone and tap it.

Tip: use the Companion app + paf serve to push builds to a device over Wi-Fi without a cable.

6. Check your environment any time

paf doctor   # verifies JDK + Android SDK
paf info     # prints the current project's config

Next: Project Structure and the CLI Reference.

Clone this wiki locally