question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"useRouter" and "useRoute" not exported

See original GitHub issue

Environment


  • Operating System: Linux
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27307420.6a25d3e
  • Package Manager: npm@8.1.0
  • Bundler: Vite
  • User Config: meta, buildModules, ssr, srcDir, css, publicRuntimeConfig
  • Runtime Modules: -
  • Build Modules: @pinia/nuxt@0.1.5

Reproduction

As the title says, useRouter and useRoute can’t be imported

import {  useRoute } from '#app';

// useRoute is not exported from the 'app'

Describe the bug

I am trying to import useRoute as stated here so I can get the path and route name, however, they are not exported.

Currently using a workaround by accessing the router from the useNuxtApp hook.

Additional context

No response

Logs

SyntaxError: The requested module '/_nuxt/@fs/home/__my_user_dir__/__my_project_folder__/node_modules/nuxt3/dist/app/index.mjs' does not provide an export named 'useRoute'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pi0commented, Dec 3, 2021

@Jasenkoo Can you try import { useRoute } from '#imports'?

1reaction
pi0commented, Dec 4, 2021

Reopening again (🙈 ) Bridge and Nuxt 3 APIs are supposed to be identical at least when possible which we could make it working always from #imports

Read more comments on GitHub >

github_iconTop Results From Across the Web

'does not provide an export named 'createRouter'' vue 3, vite ...
I just started using vite with vue. When I'm trying to use vue-router I get the error: SyntaxError: The requested module '/node_modules/.vite/ ...
Read more >
Im using VueJs and Laravel8 and i want to import vue-router ...
js :"export 'VueRouter' was not found in 'vue-router'. Im using VueJs and Laravel8 and i want to import vue-router. Her is my app.js...
Read more >
Vue Router and the Composition API
Because we don't have access to this inside of setup , we cannot directly ... import { useRouter, useRoute } from 'vue-router' export...
Read more >
useRoute - React Navigation
useRoute is a hook which gives access to route object. It's useful when you cannot pass the route prop into the component directly,...
Read more >
Using Hooks with React Router - LogRocket Blog
useParams; useNavigate; useLocation; useMatch; useRoutes ... export default function App() { return ( <div className="App"> <BrowserRouter> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found