Set up a Laravel 13 + Vue 3 app in ten minutes

Create a project with the official Vue starter kit, then add your first model, controller and typed Vue page with Inertia. Every command you need, start to finish.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/application-setup.md
Create a project with the official Vue starter kit, then add your first model, controller and typed Vue page with Inertia. Every command you need, start to finish.
Do not copy a Kernel.php from a Laravel 10 tutorial into this app.
Do not point the Vue pages at routes/api.php so they "go through bootstrap".
Do not return true for every user so a Vue admin link can open it.
Show the diff. Do not commit.

Next: Laravel Fortify with Vue

On this page · 15 sections
  1. Step 1: install the Laravel installer
  2. Step 2: create the project
  3. Step 3: start the dev servers
  4. Step 4: add a model
  5. Step 5: add a route and a controller
  6. Step 6: write the Vue page
  7. The logged-in user is already shared
  8. Step 7: test it
  9. Register routes and middleware
  10. Format PHP with Pint before you commit
  11. Install Telescope for local debugging
  12. Commit an env example, not the secrets file
  13. Recap
  14. FAQ
  15. Next steps
  16. Sources

You want a Laravel 13 app with a Vue 3 page showing data from your database, and you want it before your coffee goes cold. This guide goes from an empty folder to exactly that, with every command in order.

TL;DR

  • laravel new blog, answer yes to a starter kit and pick Vue: login, Inertia 3, TypeScript and Tailwind are wired up.
  • composer run dev starts PHP, the queue, logs and Vite in one command.
  • A controller returns Inertia::render('posts/Index', [...]); the Vue page types those props with defineProps. No API to build.

What you'll learn

  • How to create a project with the Vue starter kit
  • How to add a model, migration, factory and seeder
  • How a controller sends typed props to a Vue page
  • How to test the page with Pest

Who it's for: Developers starting their first Laravel + Vue app

Applies to: Laravel 13 · Vue starter kit · Inertia 3 · Vue 3.5 · TypeScript · Pest

You need PHP 8.3+, Composer and Node.js (see what you need).

  1. Install the Laravel installer.
  2. Create the project with the Vue starter kit.
  3. Start the dev servers.
  4. Add a model with a migration, factory and seeder.
  5. Add a route and a controller.
  6. Write the Vue page.
  7. Test it.

Step 1: install the Laravel installer#

bash
composer global require laravel/installer

Make sure Composer’s global bin directory is on your PATH, so the laravel command is available.

Step 2: create the project#

bash
laravel new blog

The installer asks a few questions. Answer yes to a starter kit.

Gotcha: the defaults are not Vue

The starter kit default is no. Saying no, then picking Vue, installs Vue with no login. On the stack question, the default is React.

QuestionAnswer
Starter kit?Yes
Starter kit stackVue
AuthenticationLaravel’s built-in authentication
TeamsNo, unless you want them

Pest is installed for you. Pass --phpunit if you want PHPUnit instead. The installer does not show a testing-framework question.

It then installs Composer and npm dependencies, creates a SQLite database and runs the first migrations. The Vue kit ships with Inertia 3, Vue 3, TypeScript, Tailwind CSS 4 and shadcn-vue.

Step 3: start the dev servers#

bash
cd blog
composer run dev

This one command starts the PHP server, the queue worker, the log viewer and Vite with hot reload. Open http://localhost:8000 and you will see the welcome page, with working Log in and Register links.

Step 4: add a model#

Create a Post model with a migration, a factory and a seeder:

bash
php artisan make:model Post -mfs

Describe the table in the new migration:

database/migrations/xxxx_xx_xx_create_posts_table.phpphp
public function up(): void
{
    Schema::create('posts', function (Blueprint $table) {
        $table->id();
        $table->string('title');
        $table->string('slug')->unique();
        $table->text('excerpt');
        $table->timestamp('published_at')->nullable();
        $table->timestamps();
    });
}

Let the model be filled in bulk, and give the factory some fake data:

app/Models/Post.phpphp
class Post extends Model
{
    use HasFactory;

    protected $fillable = ['title', 'slug', 'excerpt', 'published_at'];

    protected function casts(): array
    {
        return ['published_at' => 'datetime'];
    }
}
database/factories/PostFactory.phpphp
public function definition(): array
{
    $title = fake()->sentence();

    return [
        'title' => $title,
        'slug' => str($title)->slug(),
        'excerpt' => fake()->paragraph(),
        'published_at' => now(),
    ];
}
database/seeders/PostSeeder.phpphp
public function run(): void
{
    Post::factory()->count(12)->create();
}

Run the migration and seed the table:

bash
php artisan migrate
php artisan db:seed --class=PostSeeder

Step 5: add a route and a controller#

bash
php artisan make:controller PostController
app/Http/Controllers/PostController.phpphp
use App\Models\Post;
use Inertia\Inertia;
use Inertia\Response;

class PostController extends Controller
{
    public function index(): Response
    {
        return Inertia::render('posts/Index', [
            'posts' => Post::query()
                ->latest('published_at')
                ->get(['id', 'title', 'slug', 'excerpt', 'published_at']),
        ]);
    }
}
routes/web.phpphp
use App\Http\Controllers\PostController;

Route::get('/posts', [PostController::class, 'index'])->name('posts.index');

Step 6: write the Vue page#

Inertia passes the controller’s data to the page as props. With <script setup> and TypeScript, they are fully typed:

resources/js/pages/posts/Index.vuevue
<script setup lang="ts">
import { Head } from "@inertiajs/vue3";

interface Post {
  id: number;
  title: string;
  slug: string;
  excerpt: string;
  published_at: string;
}

defineProps<{ posts: Post[] }>();
</script>

<template>
  <Head title="Posts" />

  <main class="mx-auto max-w-3xl space-y-6 p-8">
    <h1 class="text-3xl font-semibold">Posts</h1>

    <article v-for="post in posts" :key="post.id" class="rounded-xl border p-6">
      <h2 class="text-xl font-medium">{{ post.title }}</h2>
      <p class="mt-2 text-muted-foreground">{{ post.excerpt }}</p>
    </article>
  </main>
</template>

Visit http://localhost:8000/posts. Vite reloads the page as you edit, and Laravel serves the data. There is no separate API to build.

The logged-in user is already shared#

The Vue starter kit already shares the logged-in user from HandleInertiaRequests.php as auth.user. A layout reads it with usePage().props.auth.user.

Gotcha: new secret columns

The default User model hides password, two_factor_secret, two_factor_recovery_codes, and remember_token with the Hidden attribute. A secret column you add later goes on that same attribute, or you share only(['id', 'name', 'email']) instead of the whole model.

The title template and a meta description are the document title guide. The shell that stays mounted between those pages is the persistent layout guide.

Step 7: test it#

Write and run the first test

tests/Feature/PostsTest.phpphp
use App\Models\Post;

it('lists posts', function () {
    Post::factory()->create(['title' => 'Hello Laravel 13']);

    $this->get('/posts')
        ->assertOk()
        ->assertInertia(fn ($page) => $page
            ->component('posts/Index')
            ->has('posts', 1)
        );
});
bash
php artisan test

Register routes and middleware#

Laravel 11 and newer register routes, middleware, and the health URL in bootstrap/app.php. The starter kit already has this file. You do not get app/Http/Kernel.php.

php
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        //
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();

Web routes, including Inertia, stay in routes/web.php. Middleware aliases go in the withMiddleware callback. You do not get a $routeMiddleware array anymore.

Gotcha

Do not copy a Kernel.php from a Laravel 10 tutorial into this app. The framework will not read it. Do not point the Vue pages at routes/api.php so they “go through bootstrap”. They are web routes.

Format PHP with Pint before you commit#

shell
vendor/bin/pint --dirty

--dirty limits Pint to git’s dirty files. Commit after you have looked at the diff. Pint rewrites spacing and imports. It does not change a query’s meaning on purpose, but you still read the diff.

Vue, TypeScript, and CSS are not Pint’s job. The kit’s frontend formatter, if you have one, is a different command.

Gotcha

Do not commit vendor/. Pint lives there after composer install. CI can run vendor/bin/pint --test so a bad format fails the build without rewriting the branch.

Install Telescope for local debugging#

Telescope records request bodies, including Inertia props and the session. That is useful on your machine. It is not a product feature, and the Vue page should not iframe it.

shell
composer require laravel/telescope --dev
php artisan telescope:install
php artisan migrate

The published TelescopeServiceProvider gates viewTelescope. Leave that gate on local. Do not return true for every user so a Vue admin link can open it. Do not require Telescope without --dev and then try to prune it later. CI does not need the UI.

Commit an env example, not the secrets file#

.env has the app key and the database password. It stays off the git remote. Commit .env.example instead, with the key names and empty secrets:

ini
APP_NAME=Laravel
APP_KEY=
APP_URL=http://localhost

VITE_APP_NAME="${APP_NAME}"

A teammate copies it to .env and fills it in. APP_KEY is generated with php artisan key:generate. You do not invent one and you do not reuse production’s. Vite only sees VITE_ keys; the Vite guide is which of those values the browser is allowed to see.

Gotcha

Do not prefix a secret with VITE_ so the example “also works in Vue”. That ships the secret. Do not add .env to the repo and gitignore it later. It is already in history. Rotate the key that leaked.

Recap#

  • laravel new blog + Vue starter kit = auth, Inertia 3, Vue 3, TypeScript and Tailwind on day one.
  • composer run dev runs everything you need locally.
  • make:model Post -mfs gives you the migration, factory and seeder in one go.
  • Controllers send props with Inertia::render; pages type them with defineProps.
  • Routes and middleware live in bootstrap/app.php, not Http/Kernel.php.
  • Format PHP with vendor/bin/pint --dirty, keep Telescope and .env off the remote, and commit .env.example.

FAQ#

Why did laravel new install Vue without a login screen?

You answered no to the starter kit question. Run it again and answer yes, then pick Vue.

Do I need to build an API for the Vue page?

No. With Inertia, the controller passes data to the page as props. You only need an API for other clients.

How do I use PHPUnit instead of Pest?

Pass --phpunit to laravel new. The installer does not ask about the testing framework.

Which database does a new Laravel app use?

SQLite, created for you by the installer. Switch to MySQL, MariaDB or PostgreSQL when production needs it.

Do I need app/Http/Kernel.php in Laravel 13?

No. Register routes, middleware, and the health URL in bootstrap/app.php. The framework will not read a Kernel.php copied from a Laravel 10 tutorial.

Should I commit .env so the next laptop works?

No. Commit .env.example with empty secrets. Generate a new APP_KEY on each machine with php artisan key:generate.

Can I install Telescope in production to watch Inertia requests?

No. Keep it a dev dependency and leave the viewTelescope gate on local. It records request bodies, including passwords if you are not careful.

Next steps#

Looking for the original Laravel 5 + Nuxt 2 setup of this site? It is in the repository’s Git history, from before the Astro migration.

Sources#

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.