Skip to main content
lua-spa logo

LUA-SPA

Backend-first SPA framework in Python.

This project includes:

  • LuaTemplate 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/lua_template/spa.config.json

Requirements

  • Python 3.10+
  • Poetry installed

How to use

Install locally (development)

poetry install

Create a new project

lua-spa create my_project
lua-spa create my_project ./apps

Create a component from template

lua-spa new component UserCard
lua-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 lua-spa serve

Enable hot reload:

poetry run lua-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

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

Tests

poetry run pytest

With coverage:

poetry run pytest --cov=src/lua_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 /__lua_spa_action bridge. When actions/lifecycle mutate data, those keys are patched back to client props automatically.

Metadata

Release files for lua-spa 1.2.1

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

Source distribution (sdist)

Source distribution for lua-spa 1.2.1
File Size Uploaded
lua_spa-1.2.1.tar.gz 2.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for lua-spa 1.2.1
File Interpreter ABI Platform
lua_spa-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 MB

Release files / lua_spa-1.2.1.tar.gz

Download URL lua_spa-1.2.1.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
65b346ab6d1db2f61f1a1d48a95b69179bde3a6382cbdcf55e399c497ad01348
BLAKE2b-256 checksum
How to use checksums
49d251696f10d63620a73fdea6aee924aaf75f54baa3b0f2c048fee67bb583c9
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 11, 2026.

Transparency log

Release files / lua_spa-1.2.1-py3-none-any.whl

Download URL lua_spa-1.2.1-py3-none-any.whl
Size 2.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ad030cdff9c5b3cf2163aa0f29b8232042b5ac242ee6c8de3411fb4649365fdb
BLAKE2b-256 checksum
How to use checksums
e5ec84f670cfb708337aba75b5edcfcfc512c3f498acc5c2da4de6b55298f6f8
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 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

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