Momentum for Craft CMS

Momentum is a Craft 6 plugin. Craft 6 is still in beta, and so is Momentum (6.0.0-beta.1) — try it on staging first and use caution on production sites.

Craft 6 · Beta — use caution on production

Vue, React or Svelte pages, routed by Craft

Craft 6 already runs its control panel on Inertia. Momentum does the same for your site: set a section's template to inertia:Pages/Article and Craft's own routing hands that entry to your component as props. Statuses, sites, structures and live preview keep working, and there's no API to design.

Momentum

A section setting and a component

Set the section's template, write the component. The entry's field layout becomes its props: assets with transform URLs, relations, Matrix blocks, CKEditor HTML around nested entries.

vue
<!-- Section template: inertia:Pages/Article -->
<script setup>
import { Link } from '@inertiajs/vue3';
defineProps({ entry: Object, alternates: Array });
</script>

<template>
  <h1>{{ entry.title }}</h1>
  <img :src="entry.fields.hero[0]?.transforms.wide" :alt="entry.fields.hero[0]?.alt" />
  <template v-for="chunk in entry.fields.body.chunks">
    <div v-if="chunk.type === 'markup'" v-html="chunk.html" />
    <Callout v-else :entry="chunk.entry" />
  </template>
  <Link v-for="rel in entry.fields.related" :href="rel.url">{{ rel.title }}</Link>
</template>

Features

Craft keeps the content and the routing. Your front end gets clean, typed, eager-loaded props.

Craft routing, Inertia pages

Sections whose template is inertia:<Component> render as Inertia pages; every other section keeps its Twig or Blade templates, so a site can move over one section at a time. Your own Laravel routes can render components too.

Every field type, as props

Assets with named transform URLs, relations to the depth you choose, Matrix and Content Block entries, CKEditor HTML split around nested entries, Link, Money, options, tables. Exclude or rename any field, per entry type.

  • Users are only ever {id, name}; Addresses are never sent
  • Eloquent elements respect the model's $hidden

No N+1 queries

Relations and nested entries are eager loaded level by level from the field layouts. A page with nine Matrix blocks costs the same queries as one with four.

Preview, multi-site, GraphQL

Live preview and share links render through the same component. Props follow the current site, with an alternates list for language switchers. The momentumPage GraphQL query returns the same props, limited to what the schema can read.

Twig and Blade

Root templates in either engine: inertia(page) in Twig, @inertia in Blade, identical output. momentum.props(entry) hands the same props to a Vue island on a server-rendered page.

Pro: types, SSR, deferred props

craft:momentum:types writes TypeScript declarations for every page's props. Server-side rendering runs through Inertia's SSR server for site pages only, and falls back to client rendering if it's down. Heavy fields can load as deferred props.

Frequently Asked Questions

The questions worth answering before you install it.

Try it on staging today

Lite is free; Pro's price is still to be set. Momentum is a Craft 6 beta plugin on a beta CMS — start on a development or staging site and use caution on production.

More plugins

Pairs well with Momentum