Skip to main content

Backend-first SPA framework in Python.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lua_spa-1.2.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lua_spa-1.2.0-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file lua_spa-1.2.0.tar.gz.

File metadata

  • Download URL: lua_spa-1.2.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lua_spa-1.2.0.tar.gz
Algorithm Hash digest
SHA256 775378dc157c266bb92439dbd09ab83e0dbbbba1f61d293bf2e7509b1ff05cae
MD5 14d38f38f2a61ea7a2eb7b5efc98e9b7
BLAKE2b-256 428b72ba24b40d36f08b616f3a0eeb7ef436c002d137f267b17e27cde6a331d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lua_spa-1.2.0.tar.gz:

Publisher: release-and-deploy.yaml on roderiano/lua-spa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lua_spa-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: lua_spa-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lua_spa-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3396104c0bffd3cd326d39b217680dc7d8fb2473878a065fe1c5d97497317b0
MD5 bb9c54119ee0d6c132e2fb7fa2a12259
BLAKE2b-256 87d6807b3b03e27c1fd941c63c26c0e1318be5a8cabc96e3fc685ef15f57aaac

See more details on using hashes here.

Provenance

The following attestation bundles were made for lua_spa-1.2.0-py3-none-any.whl:

Publisher: release-and-deploy.yaml on roderiano/lua-spa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page