Fragment swaps.
Native transitions.
A hypermedia library that intercepts links and forms, fetches the target URL, and swaps matching HTML fragments — built around the View Transitions API for native, CSS-driven animations.
npm install @erikt/ajax
Declarative
Register CSS selectors as swap targets. One fetch can update multiple independent fragments in the same page.
View Transitions
Every swap runs inside document.startViewTransition. Name
the transition type, write the CSS — no JavaScript animation logic.
Plugin system
A middleware pipeline exposes every stage of the lifecycle. Built-in plugins cover history, loading states, morphing, and preloading.
Zero overhead
Ships as a single ES module at 4.2 kB gzipped. No dependencies, no polyfills, no framework assumptions.
Example
import ajax, { history, loading } from '@erikt/ajax'
ajax.use(loading())
ajax.register({
target: 'nav a',
transitions: ['fade'],
plugins: [history('push')],
swaps: [
{ replace: '#main' },
],
})