bramdeleeuw / silverstripe-inertia
Inertia server-side adapter for SilverStripe
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- silverstripe/framework: >=4.0
This package is auto-updated.
Last update: 2024-12-06 03:42:12 UTC
README
This module is a still Work In progress, and help/pr's would be much appreciated!
Inertia allows you to create fully client-side rendered, single-page apps, without much of the complexity that comes with modern SPAs. It does this by leveraging existing server-side frameworks.
Installation
Install the module trough composer:
composer require bramdeleeuw/silverstripe-inertia
Add $Inertia to your Page.ss layout.
$Inertia($pageJson)
This wil render the following snippet:
<div id="app" data-page="{the page data}"></div>
In your controller you can now add the following method to populate your vue/react/etc. app.
<?php use SilverStripe\CMS\Controllers\ContentController; use Inertia\Inertia; class PageController extends ContentController { public function index() { return Inertia::render('Page', [ 'title' => $this->Title, 'content' => $this->Content ]); } }
On initial request this will populate the data-page
with the passed props. Following request made by Inertia will receive the passed props as json.