} from './types'
import { onBeforeRouteLeave } from './navigationGuards'
-// declare module '@vue/runtime-core' {
-// interface Inject {
-// (name: 'router'): Router
-// (name: 'route'): Ref<RouteLocationNormalized>
-// }
-// function inject<T>(key: InjectionKey<T> | string): T | undefined
-// function inject<T>(key: InjectionKey<T> | string, defaultValue: T): T
-// function inject(key: InjectionKey<any> | string, defaultValue?: unknown): any
-// export function inject(name: 'router'): Router
-// export function inject(name: 'route'): Ref<RouteLocationNormalized>
-// }
+export { RouteLocationOptions } from './types'
-export * from './injectKeys'
+export { useRoute, useRouter } from './injectKeys'
export {
createHistory,
-import { InjectionKey, Ref } from 'vue'
+import { InjectionKey, Ref, inject } from 'vue'
import { Router, RouteLocationNormalized } from '.'
export const routerKey = ('router' as unknown) as InjectionKey<Router>
export const routeKey = ('route' as unknown) as InjectionKey<
Ref<RouteLocationNormalized>
>
+
+export function useRouter(): Router {
+ return inject(routerKey)!
+}
+
+export function useRoute(): Ref<RouteLocationNormalized> {
+ return inject(routeKey)!
+}