NuxtN
Nuxt15mo ago
Theiaz

How to pass props to a page?

Hi,
I'm migrating my vue app to Nuxt and facing an issue with my page component using a prop. I I've seen the exact same question on stackoverflow, however it wasn't answered for Nuxt3.
https://stackoverflow.com/questions/60443520/how-to-pass-props-to-a-page-in-nuxt

Thats the page component:
// //pages/[id]/index.vue
<script setup lang="ts">
const props = defineProps<{
    id: string
}>()

console.log('id is ', props.id) // undefined
</script>

<template>
...
</template>


I want to avoid using the route.params solution (bad practice). Are there any other possibilities?
Stack Overflow
All I'm trying to do is pass a parameter to a page in Nuxt. In Vue, it's easy:

<router-link :to="{ name: 'user', params: { userId: 123 }}">User</router-link>
or

<router-link to="/...
Was this page helpful?