justinholtweb / craft-momentum
Render Craft entries as Inertia pages (Vue, React or Svelte) straight from Craft routing — no headless API, no second router.
Package info
github.com/justinholtweb/craft-momentum
Type:craft-plugin
pkg:composer/justinholtweb/craft-momentum
Requires
- php: ^8.5
- craftcms/cms: ^6.0.0-beta.1
Requires (Dev)
- larastan/larastan: ^3.13
- laravel/pint: ^1.22
- orchestra/testbench: ^11.0
- pestphp/pest: ^5.0
- pestphp/pest-plugin-laravel: ^5.0
- phpstan/phpstan: ^2.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-19 13:46:08 UTC
README
Render Craft entries as Inertia pages (Vue, React or Svelte) straight from Craft routing — no headless API, no second router.
Warning
Craft 6 only, and in beta. Momentum is a native Craft CMS 6 plugin. Craft 6 is still in beta,
and so is Momentum (6.0.0-beta.1). Try it on development and staging sites first and use caution on
production: keep backups, and expect changes between betas. It does not run on Craft 5.
Docs: justinholt.com/plugins/craft-momentum (also in docs/). See PLAN.md.
Requirements
- Craft CMS 6.0.0-beta.1 or later (native Craft 6 plugin, no Yii 2 adapter)
- PHP 8.5
inertiajs/inertia-laravelv3 — already required by Craft 6 core (the CP is an Inertia app), so no new dependency- An Inertia v3 front end (
@inertiajs/vue3,@inertiajs/reactor@inertiajs/svelte) built with Vite
How it works
- Point a section at a component. Set the section's Template to
inertia:Pages/Article. Craft still routesarticles/{slug}(statuses, sites, structures as usual); Momentum answers with thePages/Articlecomponent. Other sections keep their Twig/Blade templates. - The entry arrives as props, built from its field layout: every core field type has a transformer
(assets with named transforms, relations to Relation depth, Matrix and Content Block entries, CKEditor
HTML split into chunks around nested entries, Link, options, Money, Table…). Relations and nested entries
are eager loaded level by level, so a page costs a query per field per level, not per element.
Users are only
{id, name}, Addresses are never sent, Eloquent elements respect the model's$hidden. - Shared props:
site,currentUser({id, name}or null),errors, and on multi-site installsalternates(the entry's URL on every site, for language switchers). - Root template: first visits render
_momentum/rootor your own Twig ({{ inertia(page) }}) or Blade (@inertia) template, loading your Vite entry points. - Live preview and share links render the draft through the same component.
Everything in props is public. Exclude private fields under Excluded fields (handle or
entryType.handle), rename with handle: propName, or reshape props with the EntryPropsResolving event.
Route::get('search', fn (\JustinHoltWeb\Momentum\Momentum $m) => $m->render('Pages/Search', ['q' => request('q')])) ->middleware(['web', 'craft', 'craft.web']);
Twig and Blade: momentum.props(entry) / $momentum->props($entry) return the same props an Inertia page
gets; momentum.componentFor(entry) its component.
GraphQL: momentumPage(id | uri, site) returns {component, url, site, props} for schemas given Read
Momentum page props; related entries, assets and users are kept only when the schema could fetch them itself.
Editions
Lite (free): everything above. Pro (price TBD):
- Typed props —
php artisan craft:momentum:typeswrites TypeScript declarations per entry type and aMomentumPagescomponent → props map. - Server-side rendering through Inertia's SSR server, for site pages only (the CP is untouched), falling back to client-side rendering if the server is unreachable.
- Deferred fields — heavy fields sent as Inertia deferred props and fetched after the page renders.
Development
composer install composer test # Pest composer phpstan # Larastan level 6 composer check-cs # Pint
Tested in the Craft 6 harness at ~/Sites/plugin-testing-craft6 (bin/plugin-wire craft-momentum --install).
Live checks: tests/Harness/check.sh — self-contained fixtures (every core field type, CKEditor with nested
entries, a temporary second site, GraphQL schemas, a real Vue 3 + Inertia SSR server) and cleanup.
Browser-verified with Vue 3 + @inertiajs/vue3 (tests/Harness/frontend/).