Skip to content

useRoute()

Get the current route location information. Must be called inside a Vue component's setup() function.

Type

ts
function useRoute(): RouteLocation

Return Value

Returns the current RouteLocation snapshot.

WARNING

Returns a snapshot of the route location at the time of the call. It does not automatically react to subsequent route changes.

Thrown Errors

Error CodeCondition
SETUP_ERRORCalled outside setup
SETUP_ERRORRouter not installed via app.use(router)

Example

vue
<script setup lang="ts">
import { useRoute } from '@meng-xi/uni-router'

const route = useRoute()
console.log(route.path)
console.log(route.query)
console.log(route.meta.title)
</script>

Released under the MIT License.