Pagefold

v0.3.1 · MIT

Pages that fold into each other.

Page transitions for server-rendered websites. Keep your HTML, add one container and one line of JavaScript.

01 · A click

Someone clicks a link.

Pagefold catches it before the browser throws the page away.

02 · A fetch

The next page is fetched.

Plain HTML, your own server. Click twice and the first request is aborted.

03 · A fold

One container swaps.

The old page leaves, the new one arrives, and everything around them stays put.

04 · What you get

Everything it does, in six lines.

Drag to explore.

01

Works with the HTML you have

No API and no special responses. Pagefold fetches your pages and swaps one container.

02

Cancels what nobody needs

Click twice, and the first request is aborted, not left running in the background.

03

Small and modular

A 7.5 KB core with no dependencies. Every module is its own import, so you ship what you use.

04

Animate with anything

CSS, GSAP, Motion, the Web Animations API or the View Transitions API. Your choice.

05

Accessible by default

Announces the new page, moves focus, and skips motion when people ask for less of it.

06

A hook at every step

Fully typed, awaited, replaceable. Plugins use the same API you do.

05 · Three pieces

Up and running in three pieces.

1

Mark the container

<main id="pagefold" class="transition-fade">
  ...
</main>
2

Style the transition

.transition-fade { transition: opacity .3s }
html.is-animating .transition-fade {
  opacity: 0
}
3

Start it

import Pagefold from 'pagefold'

new Pagefold()

06 · Modules

Add only what you need.

Every module is a separate import, and the sizes below are what each one adds. Nothing you do not use reaches your bundle.

Fold your pages.