Skip to main content

🐍 PyReact - Framework Web Declarativo para Python

PyPI version Python License: MIT

PyReact é um framework web declarativo inspirado no React, mas construído nativamente para Python. Permite criar interfaces de usuário reativas, com componentes, hooks e renderização eficiente.


📦 Instalação

Via pip (Recomendado)

pip install pyreact-framework

Via pip (GitHub)

pip install git+https://github.com/wanbnn/pyreact.git

Desenvolvimento Local

git clone https://github.com/wanbnn/pyreact.git
cd pyreact
pip install -e .

🚀 Início Rápido

Criar um Novo Projeto

# Criar projeto
pyreact-framework create meu-app

# Entrar no diretório
cd meu-app

# Iniciar servidor de desenvolvimento
pyreact-framework dev

Exemplo de Contador

from pyreact import h, render, use_state, Component

def Counter(props):
    """Componente de contador funcional"""
    count, set_count = use_state(0)
    
    return h('div', {'className': 'counter'},
        h('h1', None, f'Contador: {count}'),
        h('button', {'onClick': lambda: set_count(count + 1)}, '+'),
        h('button', {'onClick': lambda: set_count(count - 1)}, '-')
    )

# Renderizar
root = document.getElementById('root')
render(h(Counter, None), root)

✨ Funcionalidades

Componentes Funcionais

def Button(props):
    """Componente de botão reutilizável"""
    return h('button', {
        'className': 'btn',
        'onClick': props.get('onClick')
    }, props.get('children'))

Componentes de Classe

class Counter(Component):
    """Componente de contador com estado"""
    
    def __init__(self, props):
        super().__init__(props)
        self.state = {'count': 0}
    
    def render(self):
        return h('div', None,
            h('h1', None, f'Count: {self.state["count"]}'),
            h('button', {
                'onClick': lambda: self.set_state({'count': self.state['count'] + 1})
            }, 'Increment')
        )

Hooks

from pyreact import use_state, use_effect, use_ref

def MyComponent(props):
    # Estado local
    count, set_count = use_state(0)
    
    # Efeito colateral
    use_effect(lambda: print(f'Count: {count}'), [count])
    
    # Referência
    input_ref = use_ref(None)
    
    return h('div', None, f'Count: {count}')

📖 Documentação

📚 Documentação Completa

A documentação completa está disponível no Read the Docs:

🔗 https://pyreact-framework.readthedocs.io/

Conteúdo da Documentação:

  • Getting Started

    • Installation
    • Quick Start
    • Tutorial (Todo App)
  • Core Concepts

    • Components
    • Props
    • State
    • Events
    • Lifecycle
  • Advanced

    • Server-Side Rendering (SSR)
    • Routing
    • Styling
    • Testing
  • API Reference

    • Element API
    • Component API
    • Hooks API
    • CLI API

CLI Commands

# Criar novo projeto
pyreact create <nome>

# Iniciar servidor de desenvolvimento
pyreact-framework dev [--port PORT]

# Gerar componente
pyreact generate component <nome>

# Gerar hook
pyreact generate hook <nome>

# Build para produção
pyreact build

API Principal

h(type, props, *children)

Cria um elemento virtual (VNode).

h('div', {'className': 'container'},
    h('h1', None, 'Título'),
    h('p', None, 'Parágrafo')
)

render(element, container)

Renderiza um elemento no container.

render(h(App, None), document.getElementById('root'))

create_root(container)

Cria uma raiz de renderização (API moderna).

root = create_root(document.getElementById('root'))
root.render(h(App, None))

🧪 Testes

Executar Testes

# Testes unitários
pytest tests/

# Testes E2E
pytest tests/e2e/ -v

# Com cobertura
pytest tests/ --cov=pyreact

Documentação de Testes

Ver docs/GUIA_EXECUCAO_E_TESTES.md para mais detalhes.


📁 Estrutura do Projeto

pyreact/
├── pyreact/              # Código fonte
│   ├── cli/              # Interface de linha de comando
│   ├── core/             # Núcleo do framework
│   ├── dom/              # Operações DOM
│   ├── server/           # Renderização servidor
│   └── utils/            # Utilitários
├── tests/                # Testes
│   ├── e2e/              # Testes end-to-end
│   └── unit/             # Testes unitários
├── examples/             # Exemplos
├── docs/                 # Documentação e relatórios em PDF
├── pyproject.toml        # Configuração do projeto
├── README.md             # Este arquivo
├── INSTALL.md            # Guia de instalação
├── PUBLISH.md            # Guia de publicação
└── LICENSE               # Licença MIT

🛠️ Desenvolvimento

Configurar Ambiente

# Clonar repositório
git clone https://github.com/wanbnn/pyreact.git
cd pyreact

# Criar ambiente virtual
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows

# Instalar dependências
pip install -e .

# Instalar dependências de desenvolvimento
pip install -e ".[dev]"
pip install playwright
playwright install chromium

Executar em Desenvolvimento

# Instalar em modo editável
pip install -e .

# Executar testes
pytest tests/ -v

# Criar build
python -m build

📦 Publicação

Publicação automática

Todo push em master executa testes, build e publicação no PyPI através do GitHub Actions. A autenticação usa Trusted Publishing (OIDC), sem token permanente armazenado no repositório.

Consulte docs/PUBLICACAO_AUTOMATICA.md para a configuração inicial e a estratégia de versionamento.

Build

# Limpar builds anteriores
python -c "import shutil; from pathlib import Path; [shutil.rmtree(p, ignore_errors=True) for p in ['build', 'dist', 'pyreact.egg-info']]"

# Criar build
python -m build

Publicar no PyPI

# Instalar twine
pip install twine

# Verificar build
twine check dist/*

# Publicar no TestPyPI (teste)
twine upload --repository testpypi dist/*

# Publicar no PyPI (oficial)
twine upload dist/*

Ver PUBLISH.md para mais detalhes.


🤝 Contribuindo

Contribuições são bem-vindas! Por favor:

  1. Fork o projeto
  2. Crie uma branch para sua feature (git checkout -b feature/AmazingFeature)
  3. Commit suas mudanças (git commit -m 'Add some AmazingFeature')
  4. Push para a branch (git push origin feature/AmazingFeature)
  5. Abra um Pull Request

📝 Licença

Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE para detalhes.


📞 Contato


🙏 Agradecimentos

  • Inspirado no React
  • Construído com ❤️ pela comunidade Python

Feito com ❤️ pela comunidade Python

Metadata

Release files for pyreact-framework 1.0.5.post3011875728803

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

Source distribution (sdist)

Source distribution for pyreact-framework 1.0.5.post3011875728803
File Size Uploaded
pyreact_framework-1.0.5.post3011875728803.tar.gz 63.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyreact-framework 1.0.5.post3011875728803
File Interpreter ABI Platform
pyreact_framework-1.0.5.post3011875728803-py3-none-any.whl Python 3 none any Details

Total release size: 131.0 kB

Release files / pyreact_framework-1.0.5.post3011875728803.tar.gz

Download URL pyreact_framework-1.0.5.post3011875728803.tar.gz
Size 63.7 kB
Tags Source
SHA-256 checksum
How to use checksums
50562a557b98f6334828ccae1717bfc6c2997cef5eb537533dbe573bae4edb7b
BLAKE2b-256 checksum
How to use checksums
9af5c16425913a4398ebeb0436434a68a841167ce2075cf15c103f415751af71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release files / pyreact_framework-1.0.5.post3011875728803-py3-none-any.whl

Download URL pyreact_framework-1.0.5.post3011875728803-py3-none-any.whl
Size 67.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bdc7d6c9ad4a3291d22271c721d5211d721cb5fefe5529336b5f9da7dc8697a
BLAKE2b-256 checksum
How to use checksums
2c63409aec63a49428b8124a5a2433d96de2ae62a08ebb36020df890314e10d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

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 Jul 27, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

2 release files

This release

1.0.5.post3011875728803 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

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