Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After upgrading to RC.11, useRouter() cannot be used in composable #570

Closed
szulcus opened this issue Sep 29, 2022 · 6 comments
Closed

After upgrading to RC.11, useRouter() cannot be used in composable #570

szulcus opened this issue Sep 29, 2022 · 6 comments

Comments

@szulcus
Copy link

szulcus commented Sep 29, 2022

Environment

  • Operating System: Windows_NT
  • Node Version: v16.17.1
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: ssr, head, css, plugins, components, buildModules, modules, build, vite, serverHandlers, devServerHandlers, bridge
  • Runtime Modules: -
  • Build Modules: (), @nuxt/bridge@3.0.0-27740081.058a6c1

Reproduction

nuxt-bridge-rc11.zip

Describe the bug

I used the command npx nuxi@latest upgrade --force from https://github.com/nuxt/framework/discussions/7691 and when trying to use useRouter I get the following error:

[vue-router]: Missing current instance. useRouter() must be called inside <script setup> or setup().

useRouetr is used only after clicking on the button, when the instance is ready. Everything works fine in RC.8

Additional context

How can I safely roll back to RC.8?

Logs

No response

@szulcus szulcus changed the title After upgrading to RC.11, useRouter () cannot be used in composable After upgrading to RC.11, useRouter() cannot be used in composable Sep 29, 2022
@P4sca1
Copy link

P4sca1 commented Oct 2, 2022

The same applies to useRoute(). Both are no longer callable in plugins.

@szulcus
Copy link
Author

szulcus commented Oct 2, 2022

The same applies to useRoute(). Both are no longer callable in plugins.

Is this also the case in the official version of Vue 3?

@P4sca1
Copy link

P4sca1 commented Oct 2, 2022

I only tested with Vue 2 and Nuxt bridge. I can't tell wether it works with Nuxt / Vue 3.

@MartinX3
Copy link

MartinX3 commented Oct 2, 2022

Has it something to do with the vue-router 3.6 release adding useRoute() and useRouter() as composables for vue 2.7?

@danielroe
Copy link
Member

Yes, this is because we switched to using the built-in vue-router composables. (We will need to partially revert that.)

@BrandonlinU
Copy link

Possible duplicate of #554?

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants