nuxt / framework

Old repo of Nuxt 3 framework, now on nuxt/nuxt

Home Page:https://nuxt.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

useNuxtApp().hook not working as expected

BrandanKing opened this issue · comments

Environment

  • Operating System: Windows_NT
  • Node Version: v16.17.1
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.15.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-rxxma7?file=composables/useTest.ts

Describe the bug

I am trying to hook into the Nuxt lifecycle hooks within a composable. However, it doesn't appear to be doing anything. Please can someone provide me with assistance on if I am doing it correctly.

I want to run a fetch function on app:mount / page:start

Additional context

No response

Logs

No response

Looked into this further, it seems the only hook that works in a composable is "page:finish", Can someone please explain what the best way to replicate onMounted using Nuxt lifecycle hooks.