Skip to main content
moon-spa logo

MOON-SPA

Backend-first SPA framework in Python.

This project includes:

  • Template file served by the backend
  • .lspa components (HTML + Python) with component import support
  • Client hydration at component level
  • DOM diff renderer inspired by React's virtual DOM flow
  • useState hook-style state management
  • Setup-only component contract via Component.setup(self, props)
  • Server-call bridge for callable actions and lifecycle hooks
  • Base app definitions isolated in src/moon_template/spa.config.json

Requirements

  • Python 3.10+
  • Poetry installed

How to use

Install locally (development)

poetry install

Create a new project

moon-spa create my_project
moon-spa create my_project ./apps

Create a component from template

moon-spa new component UserCard
moon-spa new component UserCard ./apps/my_project

The CLI copies ComponentTemplate, renames files/content, and prints the exact created paths.

Run the application

poetry run moon-spa serve

Enable hot reload:

poetry run moon-spa serve --reload

When reload is enabled, watcher logs use relative paths:

Live reload activated. Watching src for file changes...

Open in browser:

http://127.0.0.1:8000

Documentation

Docs are available in the docs/ directory:

Run locally:

cd docs
npx docusaurus start

Project Structure

moon-spa/
  pyproject.toml
  src/
    moon_spa/
      app.py
      codegen.py
      framework.py
      loader.py
      main.py
      renderer.py
      router.py
      scope.py
      server.py
      runtime_assets.py
    moon_template/
      index.lspa
      spa.config.json
      components/
  tests/

Tests

poetry run pytest

With coverage:

poetry run pytest --cov=src/moon_spa --cov-report=term

Component Format

Components are .lspa files composed of:

  • optional imports
  • <python> block with a Component subclass implementing setup(self, props)
  • <template> block (HTML)

setup(self, props) can return a mapping with props, state, data, actions, and lifecycle, or omit return and let the server infer these sections from local variables/functions. Callable actions and lifecycle entries are executed through the POST /__moon_spa_action bridge. When actions/lifecycle mutate data, those keys are patched back to client props automatically.

Metadata

Release files for moon-spa 2.4.3

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

Source distribution (sdist)

Source distribution for moon-spa 2.4.3
File Size Uploaded
moon_spa-2.4.3.tar.gz 2.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for moon-spa 2.4.3
File Interpreter ABI Platform
moon_spa-2.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 MB

Release files / moon_spa-2.4.3.tar.gz

Download URL moon_spa-2.4.3.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
a5dd0c8fd2807b5308ea64f310f67c4b03b83940fb942b0a04fe15c26b2c8269
BLAKE2b-256 checksum
How to use checksums
e04987fdb267e43aa9e0581bae8555f91a76c1e08522d29307e3f52d89026f9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 15, 2026.

Transparency log

Release files / moon_spa-2.4.3-py3-none-any.whl

Download URL moon_spa-2.4.3-py3-none-any.whl
Size 2.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2499f07f44cd41704eedc9de38026fa79c692d9c92a5fccc7fca1acdd0d56c89
BLAKE2b-256 checksum
How to use checksums
6c4508d577310e985115f5a4684ea01869215e52a718dd0ebd0bb60d3e3cce95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.4.3 This release

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.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