<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Zyppon</title>
    <description>The latest articles on Forem by Zyppon (@zyppon).</description>
    <link>https://forem.com/zyppon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1193318%2F83c05ae2-22d3-4bee-8dc9-23734cb782d7.jpg</url>
      <title>Forem: Zyppon</title>
      <link>https://forem.com/zyppon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/zyppon"/>
    <language>en</language>
    <item>
      <title>Nuxt 3 + Supabase: targetUserId undefined in Chat Component</title>
      <dc:creator>Zyppon</dc:creator>
      <pubDate>Fri, 17 Oct 2025 04:33:50 +0000</pubDate>
      <link>https://forem.com/zyppon/nuxt-3-supabase-targetuserid-undefined-in-chat-component-2a1f</link>
      <guid>https://forem.com/zyppon/nuxt-3-supabase-targetuserid-undefined-in-chat-component-2a1f</guid>
      <description>&lt;p&gt;Hi everyone,&lt;/p&gt;

&lt;p&gt;I’m building a real-time chat feature using Nuxt 3 and Supabase. My goal is to have a DM system similar to Discord. I’m passing currentUserId and targetUserId as props from a page to a Chat.vue component, but I keep running into the same issue:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;handleSend: targetUserId is undefined!&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Even though the URL has the correct UUID of the friend (/me/dm/), when I try to send a message in the chat component, targetUserId is undefined. I’ve tried:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using watch on props to detect when they are available.&lt;/li&gt;
&lt;li&gt;Using v-if="currentUserId &amp;amp;&amp;amp; targetUserId" before mounting .&lt;/li&gt;
&lt;li&gt;Logging route.params.id in the parent page — it shows correctly on onMounted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything seems fine in the parent, but inside the Chat component, the prop is undefined at the time handleSend is called. I suspect it might be related to Nuxt 3 SSR / hydration timing, but I’m not sure.&lt;/p&gt;

&lt;p&gt;Here’s a snippet from my parent page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Chat
  v-if="currentUserId &amp;amp;&amp;amp; targetUserId"
  :currentUserId="currentUserId"
  :targetUserId="targetUserId"
/&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in &lt;code&gt;Chat.vue&lt;/code&gt; component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const props = defineProps({
  currentUserId: String,
  targetUserId: String
})

const handleSend = () =&amp;gt; {
  if (!props.targetUserId) {
    console.error('handleSend: targetUserId is undefined!', props)
    return
  }
  sendMessage(props.targetUserId)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I’ve been debugging for hours and still can’t figure out why targetUserId is undefined in the component, even though the URL is correct and v-if should prevent mounting too early.&lt;/p&gt;

&lt;p&gt;Has anyone faced a similar issue in Nuxt 3? Could it be an SSR timing problem, or am I missing something obvious about passing props?&lt;/p&gt;

&lt;p&gt;Any advice or workarounds would be greatly appreciated.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

&lt;h1&gt;
  
  
  webdev #javascript #nuxt #nuxt3 #supabase
&lt;/h1&gt;

</description>
      <category>help</category>
      <category>javascript</category>
      <category>vue</category>
    </item>
  </channel>
</rss>
