A lightweight implementation of Inertia.js v2 with plain PHP and Svelte 5. No frameworks required.
This version uses Svelte, but there's also a Vue version
Full blog and blog CMS using Inertia, Svelte and SQLite example here
Modern PHP comes with many powerful features built-in:
This project leverages these capabilities while adding just what you need to build modern SPAs:
# Clone the repository using degit (no git history)
npx degit dashpilot/inertia-vanilla-php-svelte my-project
# Navigate to project directory and install dependencies
cd my-project
composer install
npm install
Run both the Vite dev server and PHP server concurrently:
# Start both servers with a single command
npm run dev
This will start:
Always access your app through http://localhost:8000
Build your assets for production:
# Build optimized assets
npm run build
Set $isProduction
in config.php
to true
Then deploy your application to your production server. In production, all assets are served directly from the public/assets
directory.
Inertia::render('PageName', ['prop' => 'value'])
This implementation is specifically configured to work with Svelte 5 and Inertia.js v2, using:
mount
from Svelteuse:inertia
for linksThe PHP backend remains simple and focused:
Enjoy the simplicity of vanilla PHP with the power of modern frontend tooling!