server.view_transitions

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

View Transitions bridge — tiered setup for the View Transitions API.

Three modes controlled byAppConfig.view_transitions:

  • False / "off"— inject nothing (default).
  • True / "htmx"— inject only the script…

View Transitions bridge — tiered setup for the View Transitions API.

Three modes controlled byAppConfig.view_transitions:

  • False / "off"— inject nothing (default).
  • True / "htmx"— inject only the script snippet so htmx swaps animate via the same-document View Transitions API (baseline in all browsers since October 2025).
  • "full"— inject both the head snippet (MPA cross-document transitions) and the script snippet. Cross-document transitions are not yet baseline (no Firefox support as of early 2026).

Head snippet ("full" only, before </head>):

  • <meta name="view-transition" content="same-origin">— enables the browser's native cross-document View Transitions API.
  • @view-transition { navigation: auto; }— CSS at-rule that opts the page into automatic cross-document transitions.
  • Default crossfade keyframes (chirp-vt-out / chirp-vt-in) on the roottransition name. Apps can override with their own view-transition-nameCSS for per-element transitions.

Script snippet ("htmx" and "full", before </body>):

  • Sets htmx 2'shtmx.config.globalViewTransitionsand htmx 4's htmx.config.transitionsso swaps use the View Transitions API when available.
  • Idempotent guard (window.__chirpViewTransitions) prevents double-init.
  • Deferred listeners for htmx 2 (htmx:load) and htmx 4 (htmx:after:process) handle the case where htmx loads after the script (e.g.,<script defer>).

Injected into full-page HTML responses viaHTMLInjectmiddleware.

server.view_transitions

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

view_transitions_script_snippet
function
def view_transitions_script_snippet(nonce: str = '') -> str

Build the View-Transitions inline<script>(htmx + full modes).

When nonce is non-empty the<script> carries a nonce="..." attribute so it survives a nonce-based CSP that no longer ships 'unsafe-inline'. The "full"head snippet (VIEW_TRANSITIONS_HEAD_SNIPPET) is a <meta>/<style>pair governed bystyle-src, not script-src, so it is intentionally left un-nonced.

Parameters

Name Type Default Description
nonce str ''
normalize_view_transitions
function
def normalize_view_transitions(value: bool | str) -> ViewTransitionMode

Canonicalize theview_transitionsconfig value.

Returns one of"off", "htmx", or "full".

Parameters

Name Type Default Description
value bool | str

View source · /home/runner/work/chirp/chirp/site/../src/chirp/server/view_transitions.py:1