Inertia Typegen reads Scramble's OpenAPI document and writes a page type for each Inertia::render() call. This walkthrough adds it to a Laravel 12 or 13 app that already runs Scramble.

Check your versions

You need PHP 8.3+, Laravel 12 or 13 and inertia-laravel 2 or 3. On the JS side you need Node 22.18+ and Vite 6+. Scramble must be 0.13.49 or newer.

Why Scramble 0.13.49 or newer

Older Scramble versions are not supported. They have a security issue and a recursion bug. Every type the package writes comes from Scramble's document. Check your version first:

composer show dedoc/scramble 

No Scramble yet? Install it as a development dependency:

composer require --dev dedoc/scramble 

Without Scramble the package does nothing in production. That is fine. You commit the generated files, so a production build needs no PHP.

Install the package

composer require vagebond/inertia-typegen 

Add the JS part to devDependencies

The package ships its JS part inside vendor. Add it to devDependencies in package.json. The docs give the exact path. Then install:

pnpm install 

Publish the config

php artisan vendor:publish --tag="inertia-typegen-config" 

No HTTP endpoint is added by default.

Change PHP, get a new page type

Start the Vite dev server the way you always do. On Laravel Herd, Herd's PHP binary works.

Take a controller like this one:

return Inertia::render('Users/Show', [ 'user' => UserResource::make($user), 'role' => $user->role, // a PHP enum 'canEdit' => $request->user()->can('update', $user), ]); 

Add the canEdit line and save. The dev server regenerates the files after the PHP change. It only writes a file when its content changes.

The page type now has the new prop. The shape looks roughly like this:

// names depend on your config type UsersShowProps = SharedData & { user: { id: number; name: string; email: string } role: 'admin' | 'editor' canEdit: boolean } 

The JSON resource keeps its real shape. The enum becomes a union of its values. Shared data from your Inertia middleware is one type that each page type includes.

Keep CI in sync

The CLI writes the same files as the dev server. It needs no running server. A CI check fails when the committed files are stale.

One caveat

The package is 0.x. Minor releases can contain breaking changes until 1.0. Pin the version and read the changelog before you update.

The docs cover route helpers for named routes, form requests and plugins:

https://baken.vagebond.nl/r/CRpZg5f3