Skip to main content

Build static sites with Python code instead of template engines

Project description

Nitro CLI

A static site generator that lets you build websites using Python and nitro-ui.

Features

  • Python-Powered - Write pages in Python with nitro-ui instead of template languages
  • Live Reload - Development server with automatic browser refresh
  • Incremental Builds - Only rebuild changed pages
  • Dynamic Routes - Generate pages from data with [slug].py pattern
  • Draft Pages - Mark pages as drafts to exclude from production builds
  • Environment Variables - Auto-load .env files with from nitro import env
  • Image Optimization - Responsive images with WebP/AVIF conversion
  • Islands Architecture - Partial hydration for interactive components
  • Plugin System - Extend the build lifecycle with nitro-dispatch hooks
  • One-Click Deploy - Netlify, Vercel, or Cloudflare Pages

Installation

pip install nitro-cli

AI Assistant Integration

Add Nitro CLI knowledge to your AI coding assistant:

npx skills add nitro-sh/nitro-cli

This enables AI assistants like Claude Code to understand Nitro CLI and generate correct nitro-ui code.

Quick Start

nitro new my-site
cd my-site
nitro dev

Visit http://localhost:3000. Build for production with nitro build.

Writing Pages

Pages are Python files in src/pages/ that export a render() function:

# src/pages/index.py
from nitro_ui import HTML, Head, Body, Title, Meta, H1
from nitro import Page

def render():
    return Page(
        title="Home",
        content=HTML(
            Head(
                Meta(charset="UTF-8"),
                Meta(name="viewport", content="width=device-width, initial-scale=1.0"),
                Title("Home"),
            ),
            Body(H1("Welcome!"))
        )
    )

Output paths mirror the file structure: src/pages/about.pybuild/about.html

Dynamic Routes

Generate multiple pages from data using [param].py naming:

# src/pages/blog/[slug].py
from nitro import Page
from nitro_datastore import NitroDataStore

def get_paths():
    data = NitroDataStore.from_file("src/data/posts.json")
    return [{"slug": p.slug, "title": p.title} for p in data.posts]

def render(slug, title):
    return Page(title=title, content=...)

Commands

Command Description
nitro new <name> Create new project
nitro init Initialize Nitro in current dir
nitro dev Start dev server with live reload
nitro build Build for production
nitro preview Preview production build
nitro routes List all routes
nitro check Validate site without building
nitro export Export site as zip archive
nitro clean Remove build artifacts
nitro deploy Deploy to hosting platform
nitro info Show project and environment info

Run nitro <command> --help for options.

Configuration

# nitro.config.py
from nitro import Config

config = Config(
    site_name="My Site",
    base_url="https://mysite.com",
    renderer={"minify_html": True},
    plugins=[],
)

Ecosystem

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.

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

nitro_cli-1.0.14.tar.gz (77.7 kB view details)

Uploaded Source

Built Distribution

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

nitro_cli-1.0.14-py3-none-any.whl (72.5 kB view details)

Uploaded Python 3

File details

Details for the file nitro_cli-1.0.14.tar.gz.

File metadata

  • Download URL: nitro_cli-1.0.14.tar.gz
  • Upload date:
  • Size: 77.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nitro_cli-1.0.14.tar.gz
Algorithm Hash digest
SHA256 b30ed808f5a8751ae4f283f818b34e4052a656cb7fa41f07c4161657673cdfae
MD5 ee7be6ed7666d680326c303606974ab8
BLAKE2b-256 1b8601f1d94dfd58e04fad3c1476ff7a5607e106104d3e51d22edaa1a86c05d1

See more details on using hashes here.

File details

Details for the file nitro_cli-1.0.14-py3-none-any.whl.

File metadata

  • Download URL: nitro_cli-1.0.14-py3-none-any.whl
  • Upload date:
  • Size: 72.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nitro_cli-1.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 83bf7092cfb2b3e6959a99b1c01d4617efbc84d683024cd473725d6a32f96e9e
MD5 845f0bf644966364956627b56272b508
BLAKE2b-256 d7e482a48b43bbae933e5cc5628168b1a9caebf0f94260585fb9040262ac3dfe

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