Installation
Install the packages
bash
pnpm add inertia-ember@beta ember-source @glimmer/component @inertiajs/viteFor TypeScript, add Glint as well (see TypeScript and Glint):
bash
pnpm add -D typescript @glint/ember-tsc @glint/templateConfigure Vite
ts
// vite.config.ts
import inertia from '@inertiajs/vite';
import ember, { framework } from 'inertia-ember/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
ember(), // compiles .gjs/.gts and decorators, resolves @ember/* from ember-source
inertia({ frameworks: [framework] }), // finds ./pages/**/*.gts for you, and wires up ssr.ts
],
});With Laravel (or Laravel Rust), add laravel-vite-plugin too. The demo's config:
ts
import inertia from '@inertiajs/vite';
import tailwindcss from '@tailwindcss/vite';
import ember, { framework } from 'inertia-ember/vite';
import laravel from 'laravel-vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig(({ isSsrBuild }) => ({
plugins: [
laravel({
input: 'resources/js/app.ts',
ssr: 'resources/js/ssr.ts',
refresh: ['resources/views/**'],
// The Rust server uses HTTP by default.
detectTls: false,
}),
ember(),
inertia({ frameworks: [framework] }),
tailwindcss(),
],
server: {
host: 'localhost',
// The app writes to storage/ and Cargo to target/: neither is a change to the frontend.
watch: { ignored: ['**/storage/**', '**/target/**'] },
},
// Laravel runs the SSR server from `bootstrap/ssr/app.js`.
build: isSsrBuild ? { rollupOptions: { output: { entryFileNames: 'app.js' } } } : {},
// Bundle every dependency into the SSR build, so production runs `node bootstrap/ssr/app.js` without node_modules.
...(isSsrBuild ? { ssr: { noExternal: true } } : {}),
}));Start the app
ts
// resources/js/app.ts
import { createInertiaApp } from 'inertia-ember';
import AppLayout from './layouts/AppLayout.gts';
createInertiaApp({
layout: () => AppLayout, // for pages that don't name one
title: (title) => `${title} · My app`,
progress: { color: '#e04e39' },
});@inertiajs/vite finds the pages in ./pages/**/*.gts on its own. Without it, pass resolve:
ts
const pages = import.meta.glob('./pages/**/*.gts');
createInertiaApp({ resolve: (name) => pages[`./pages/${name}.gts`]!() });The server side
Any Inertia v3 server works: Laravel, Laravel Rust, Rails, Django and so on. Its root view loads app.ts and has the <script data-page="app" type="application/json"> that v3 writes with the first page (an older <div id="app" data-page="…"> isn't read). The demo's root view, with Laravel Rust's template syntax:
html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="preconnect" href="https://fonts.bunny.net" />
<link
rel="stylesheet"
href="https://fonts.bunny.net/css?family=instrument-sans:400,500,600|instrument-serif:400,400i"
/>
{{ vite("resources/js/app.ts", "resources/js/pages/" ~ page.component ~ ".gts") }} {{ inertia_head }}
</head>
<body class="antialiased">
{{ inertia }}
</body>
</html>A handler answers with a page name and its props:
rs
use laravel::inertia::{self, Page, props};
use crate::models::{Comment, Idea};
pub async fn show() -> laravel::Result<Page> {
let ideas = Idea::query().count().await?;
let comments = Comment::query().count().await?;
Ok(inertia::render("Welcome", props! { ideas, comments }))
}Next steps
- Pages and layouts: what a page component looks like.
- Forms: sending data back.
- Server-side rendering: full HTML on the first visit.