[Vuejs]-How to get redirected to a welcome page with a passed username prop using Inertia.js in Laravel 9?

0👍

There’s no need for you to pass the username of the authenticated user and just redirect to the Welcome page. The HandleInertiaRequest middleware will handle that for you. If you want to access the authenticated user information you can just use the usePage()

Inside <script setup> tag

<script setup>
import { computed } from 'vue'
import { usePage } from '@inertiajs/vue3'

const username = computed(() => {
    usePage().props.auth.user.username
})
</script>

Inside the <template> tag

<template>
    <span>{{ $page.props.auth.user.username }}</span>
<template>

Leave a comment