CLI API
PyReact provides a command-line interface for creating and managing projects.
Installation
The CLI is installed with PyReact:
pip install pyreact-framework
Commands
pyreact-framework create
Create a new PyReact project.
pyreact-framework create <project-name> [options]
Arguments:
project-name- Name of the project (required)
Options:
--template- Template to use (default: ‘default’)--no-git- Skip git initialization
Examples:
# Create basic project
pyreact-framework create my-app
# Create from template
pyreact-framework create my-app --template dashboard
# Create without git
pyreact-framework create my-app --no-git
pyreact-framework dev
Start the development server.
pyreact-framework dev [options]
Options:
--port- Port number (default: 3000)--host- Host address (default: ‘localhost’)--open- Open browser automatically
Examples:
# Start on default port
pyreact-framework dev
# Start on custom port
pyreact-framework dev --port 8080
# Start and open browser
pyreact-framework dev --open
pyreact-framework build
Build the project for production.
pyreact-framework build [options]
Options:
--output- Output directory (default: ‘dist’)--mode- Build mode (‘production’ or ‘development’)
Examples:
# Build for production
pyreact-framework build
# Build with custom output
pyreact-framework build --output build
pyreact-framework serve
Serve the production build.
pyreact-framework serve [options]
Options:
--port- Port number (default: 5000)--dir- Directory to serve (default: ‘dist’)
Examples:
# Serve on default port
pyreact-framework serve
# Serve on custom port
pyreact-framework serve --port 8080
pyreact-framework test
Run tests.
pyreact-framework test [options]
Options:
--watch- Watch for changes--coverage- Generate coverage report--pattern- Test file pattern
Examples:
# Run all tests
pyreact-framework test
# Run with coverage
pyreact-framework test --coverage
# Run specific tests
pyreact-framework test --pattern "test_components"
pyreact-framework –version
Display PyReact version.
pyreact-framework --version
pyreact-framework -v
pyreact-framework –help
Display help information.
pyreact-framework --help
pyreact-framework -h
Configuration
Configure your project in pyproject.toml:
[tool.pyreact]
# Entry point
entry = "src/index.py"
# Output directory
output = "dist"
# Development server
dev_port = 3000
dev_host = "localhost"
# SSR
ssr = true
# CSS Modules
css_modules = true
# Source maps
source_maps = true
Project Structure
Standard project structure:
my-app/
├── src/
│ ├── index.py # Entry point
│ ├── components/ # Components
│ │ ├── Header.py
│ │ └── Footer.py
│ ├── styles/ # Styles
│ │ └── main.css
│ └── utils/ # Utilities
├── tests/ # Tests
│ ├── test_components.py
│ └── test_utils.py
├── docs/ # Documentation
├── pyproject.toml # Configuration
└── README.md
Environment Variables
PyReact CLI respects these environment variables:
PYREACT_PORT- Default development server portPYREACT_HOST- Default development server hostPYREACT_OUTPUT- Default build output directoryNODE_ENV- Environment mode (‘development’ or ‘production’)
Best Practices
Use version control - Initialize git for your project
Configure in pyproject.toml - Centralize configuration
Use environment variables - For environment-specific settings
Run tests before build - Ensure quality before deployment
Next Steps
Quick Start - Quick start guide
Tutorial: Building a Todo App - Tutorial
Testing - Testing guide