Skip to main content

A Python UI framework mimicking React

Project description

Volta Framework

Volta is a modern, React-inspired UI framework for Python. It allows you to build component-based user interfaces using Python functions, Hooks, and a JSX-like syntax (.vpx).

Features

  • Component-Based: Build UI using functional components.
  • JSX-like Syntax: Write XML-like markup directly in Python (.vpx files).
  • Directory-Based Routing: Your file system is your router. Map folders to URLs automatically.
  • Hooks API: Manage state and side effects with use_state, use_effect, use_ref, use_context, etc.
  • Server-Side Rendering (SSR): Renders to valid HTML strings out of the box.
  • CLI Tooling: robust volta command for dev server, building, and running.
  • Hot Reloading: Instant feedback during development.
  • Smart Links: Built-in Link component detects external URLs and _blank targets automatically.

Installation

pip install volta-framework

(Or install from source with pip install -e .)

Quick Start

1. Create a Project

Initialize a new project structure:

volta init my-app
cd my-app

2. Run Development Server

Start the hot-reloading dev server:

volta dev

Volta will automatically find an available port if 3000 is in use. Open http://localhost:3000 to see your app.

Writing Components

Volta components are just Python functions that return elements.

app/App.vpx:

from volta import use_state

def Counter():
    count, set_count = use_state(0)
    
    return (
        <div>
            <p>Count: {count}</p>
            <button onClick={lambda: set_count(count + 1)}>Increment</button>
        </div>
    )

def App():
    return (
        <div>
            <h1>Welcome to Volta</h1>
            <Counter />
        </div>
    )

Routing Patterns

Volta supports two powerful routing patterns:

1. Directory-Based Routing (Recommended)

Just create folders and files inside the app/ directory.

  • app/App.vpx/
  • app/about/App.vpx/about
  • app/users/[:id]/App.vpx/users/123 (Dynamic parameters are passed as props!)
# app/users/[:id]/App.vpx
def App(id):
    return <h1>User Profile: {id}</h1>

2. Manual Routing

For complex use cases, use the built-in Router components directly.

from volta import Router, Route, Link

def App():
    return (
        <Router>
            <nav>
                <Link to="/">Home</Link>
                <Link to="/about">About</Link>
            </nav>
            <Route path="/" component={Home} />
            <Route path="/about" component={About} />
        </Router>
    )

CLI Reference

  • volta init [name]: Create a new project.
  • volta dev [--port]: Start dev server with hot reload and auto-port hunting.
  • volta run <file.vpx>: Execute a .vpx file directly.
  • volta build <file.vpx>: Transpile a .vpx file to .py.
  • volta clean: Remove cached artifacts.

Advanced Features

  • Context API: create_context, use_context.
  • Refs: use_ref.
  • Memoization: use_memo, use_callback.
  • 404 Handling: Graceful rendering of custom NotFoundPage.
  • Performance: Optimized event handling with 410 Gone for stale handlers.

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

volta_framework-0.1.3.tar.gz (134.2 kB view details)

Uploaded Source

Built Distribution

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

volta_framework-0.1.3-py3-none-any.whl (71.1 kB view details)

Uploaded Python 3

File details

Details for the file volta_framework-0.1.3.tar.gz.

File metadata

  • Download URL: volta_framework-0.1.3.tar.gz
  • Upload date:
  • Size: 134.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for volta_framework-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e6fc277ae22bb5d941fe9571da4cdf24a7003f158ceb822f47dd87977888c0b4
MD5 3a1e89f7a06e775ddce7d4792b7e78ba
BLAKE2b-256 8a5ac9210b71a1856eaea80455442005dcbb60ee0bc4ab66c365eab003ebd9e1

See more details on using hashes here.

File details

Details for the file volta_framework-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for volta_framework-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5b8f11cdf4674035c275600993870639db50b15216135b717a6493475b81499f
MD5 803f0334b7f0897c6045697a6c02d2ea
BLAKE2b-256 047d9b1a96399980fb3511309ab76a8b8ac3854fb0be72ac9d2df08da192f722

See more details on using hashes here.

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