Skip to main content

flask-inertiajs

nox codecov

Inertia v3 adapter for Flask with first-class Pydantic support.

Installation

uv add flask-inertiajs[pydantic]

Configuration

Minimal Config

from pathlib import Path

from flask import Flask
from flask_inertiajs import Inertia

app = Flask(__name__)
app.config.update(
    # Must be set
    INERTIA_VITE_MANIFEST_PATH=(
        Path(app.root_path) / 'static' / 'build' / '.vite' / 'manifest.json'
    ),
)
inertia = Inertia()
inertia.init_app(app)

Maximal Config

from pathlib import Path

from flask import Flask
from flask_inertiajs import Inertia
from flask_inertiajs.asset_version import current_asset_version
from flask_inertiajs.pydantic import PropsModel


class SharedProps(PropsModel):
    csrf_token: str


class MyComponentProps(PropsModel):
    foo: str


app = Flask(__name__)
app.config.update(
    INERTIA_TEMPLATE='inertia.html',
    INERTIA_VITE_MANIFEST_PATH=(
        Path(app.root_path) / 'static' / 'build' / '.vite' / 'manifest.json'
    ),
    SECRET_KEY='not-so-secret',
)

inertia = Inertia(
    # Throw an error if the wrong props are used with a component.
    component_prop_types={
        'MyComponent': MyComponentProps,
    },
)
inertia.init_app(app)


@inertia.share
def shared_props() -> SharedProps:
    return SharedProps(csrf_token='generate CSRF token here')


# You can override or extend the default asset version, which is calculated by hashing INERTIA_VITE_MANIFEST_PATH and INERTIA_TEMPLATE.
@inertia.asset_version
def asset_version() -> str:
    release = (Path(app.root_path) / 'release.txt').read_text().strip()
    return f'{release}-{current_asset_version()}'

Root Template

Create a template at INERTIA_TEMPLATE and use {{ inertia_root() }}:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Load your frontend JS and CSS here. -->
  </head>
  <body>{{ inertia_root() }}</body>
</html>

Usage

from flask import redirect, request, url_for, flash
from pydantic import Field

from flask_inertiajs import InertiaView
from flask_inertiajs.pydantic import FormModel, validate


class MyForm(FormModel):
    captain: str = Field(min_length=1)


class MyView(InertiaView[MyComponentProps]):
    component = 'MyComponent'
    props_model = MyComponentProps

    def make_props(self) -> MyComponentProps:
        return MyComponentProps(foo='bar')

    # `get` is registered for you but overridable.

    def post(self):
        form, errors = validate(MyForm, request.get_json())
        if form is None:  # Validation failed.
            return self.render(errors=errors)

        flash('Yay')
        return redirect(url_for('my_view'))


app.add_url_rule('/bridge', view_func=MyView.as_view('my_view'))

See the tests for more examples.

Features

These elements of the Inertia v3 protocol are currently supported:

  • Basic responses (headers/component/props/url)
  • Shared props
  • Validation errors
  • Flashes
  • Redirects
  • Asset versioning

Other elements of the Inertia v3 protocol are not currently supported but may be in the future.

Development

Copier Template

Project structure and tooling mostly derives from Coppy. See its documentation for context and additional instructions.

This project can be updated from the upstream repo, see Updating a Project.

Project Setup

From zero to hero (passing tests that is):

  1. Ensure host dependencies are installed

  2. Start docker service dependencies (if applicable):

    docker compose up -d

  3. Sync project virtualenv w/ lock file:

    uv sync

  4. Configure prek:

    prek install

  5. Run tests:

    nox

Versions

Versions are date based. A version task shows and bumps versions:

  # Show current version
  mise run version show

  # Bump version based on date, tag, and push:
  mise run version bump

  # See other options
  mise run version -- --help

Metadata

Release files for flask-inertiajs 0.20261124.1

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

Source distribution (sdist)

Source distribution for flask-inertiajs 0.20261124.1
File Size Uploaded Provenance Actions
flask_inertiajs-0.20261124.1.tar.gz 115.8 kB With provenance Details for flask_inertiajs-0.20261124.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-inertiajs 0.20261124.1
File Interpreter ABI Platform Actions
flask_inertiajs-0.20261124.1-py3-none-any.whl Python 3 none any Details for flask_inertiajs-0.20261124.1-py3-none-any.whl

Total release size: 127.0 kB

Release files / flask_inertiajs-0.20261124.1.tar.gz

Download URL flask_inertiajs-0.20261124.1.tar.gz
Size 115.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f2f46b9d99509999c3e443b51fcbd865f21e0bf9c1108ddb673171b51e415300
BLAKE2b-256 checksum
How to use checksums
65dd95f294aa6e05873dfb62d9e40480c13a6c37246cd3b7844cd6017622a9c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Release files / flask_inertiajs-0.20261124.1-py3-none-any.whl

Download URL flask_inertiajs-0.20261124.1-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f8eeb6510497edc897e78de81d52db77acd56af54ff7e4a7b3d3210f4283ccf
BLAKE2b-256 checksum
How to use checksums
c2ae34dd2be2aa2e8121f3dcf02963088032bf658de166109bdb9dd00af4df23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Security for flask-inertiajs 0.20261124.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for flask_inertiajs-0.20261124.1.tar.gz

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 Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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