pp-spa

Prisma PHP

Controls the Single Page Application (SPA) behavior of Prisma PHP. When enabled, it intercepts standard anchor link clicks to perform seamless page transitions without a full browser reload.

How it works

The directive listens for specific event triggers on the DOM. Instead of allowing the browser to unload the current page and request a new one, Prisma PHP:

  1. Intercepts the click event.
  2. Fetches the new content via XHR/Fetch.
  3. Swaps the <body> content intelligently.
  4. Updates the URL history state.
Global Activation

Enable this once in your main layout file to turn your standard PHP app into an SPA.


<body pp-spa="true">
  <!-- App Content -->
</body>

Disabling SPA (Hard Reload)

Sometimes you need a full browser refresh (e.g., logging out to clear session cookies, or linking to an external PDF/download).

You can disable the SPA behavior on a per-link basis by setting the attribute to false.

<!-- Forces a standard browser navigation -->

<a
  href="/logout"
  pp-spa="false"
>
  Log Out
</a>