Read page props from a persistent layout

A persistent layout does not receive the page props as its own props. usePage() does.

For your AI agent

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

Read https://laravel-vuejs.space/inertia-layout-child-props.md
A persistent layout does not receive the page props as its own props. usePage() does.
Do not type the layout as if post is always there.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Inertia layout props Vue” pass the post into the layout component and then the title is empty. A persistent layout wraps the page. The page owns the props. The layout guide is how the kit picks AppLayout. This page is how that layout reads a value.

TL;DR

  • A persistent layout does not receive the page props as its own props.
  • usePage() does.
  • Do not type the layout as if post is always there.
  • Do not wrap <AppLayout> inside the page template.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

vue
<script setup lang="ts">
import { usePage } from "@inertiajs/vue3";

const page = usePage();
</script>

<template>
  <header>{{ page.props.auth?.user?.name }}</header>
  <slot />
</template>

auth is shared in the setup guide. A prop you returned from one controller, such as post, is on page.props only while that page is showing. Do not type the layout as if post is always there.

What to avoid#

Gotcha

Do not wrap <AppLayout> inside the page template. The kit’s createInertiaApp already chose the layout. A second wrap renders it twice. The layout guide says the same thing.

FAQ#

How do I read page props from a persistent layout?

A persistent layout does not receive the page props as its own props. usePage() does.

What goes wrong with Inertia layout props Vue?

Many developers pass the post into the layout component and then the title is empty. Do not type the layout as if post is always there.

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.